Welcome Guest, Not a member yet? Register   Sign In
File upload
#2

Here, I just wrote this real quick works but could use some more error checking.

Place this in a helper and load it in the BaseController helpers array.

PHP Code:
/**
 *  renameFile ()
 * -----------------------------------------------------------------------
 * The path is hard coded to the WRITEPATH/uploads.
 *
 * USAGE:
 *
 * renameFile($oldFileName, $newFileName)
 *
 * $oldFileName 'robots.txt'
 * $newFileName 'test.txt'
 */
if ( ! function_exists('renameFile'))
{
    
/**
     * renameFile ()
     * -------------------------------------------------------------------
     *
     * @param  string $oldFileName
     * @param  string $newFileName
     * @return bool
     */
    
function renameFile(string $oldFileName ''string $newFileName '')
    {
        if (
$oldFileName == '' or $newFileName == '') {
            return 
false;
        }

        return 
rename(
            
WRITEPATH "/uploads/" $oldFileName,
            
WRITEPATH "/uploads/" $newFileName
        
);
    }

What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Messages In This Thread
File upload - by nfaiz - 10-14-2020, 08:58 PM
RE: File upload - by InsiteFX - 10-14-2020, 11:26 PM
RE: File upload - by nfaiz - 10-15-2020, 06:02 PM



Theme © iAndrew 2016 - Forum software by © MyBB