Flourish PHP Unframework
This is an archived copy of the forum for reference purposes

Rename with fUpload

posted by anonymous 8 years ago

Hi! How can I rename a file using fUpload? I got this:

$file = new fUpload();
$dir = new fDirectory($_SERVER['DOCUMENT_ROOT'].'/'.FOLDER.'/files');
$up = $file->move($dir, 'file_name'); //file_name is the html field

Thanks!

I'm doing this

  $cam = new fFile($pathW.$file_name);
  $cam->rename('new_name', TRUE);

It will be nice if fUpload has an option.

posted by anonymous 8 years ago

Since fFile allows chaining, the following should work:

$file = new fUpload();
$dir  = new fDirectory($_SERVER['DOCUMENT_ROOT'].'/'.FOLDER.'/files');
$up   = $file->move($dir, 'file_name')->rename('my_new_filename');
posted by wbond 8 years ago

HELLO how can i rename the uploader file and keep the extension cause when iuse your code it remove the extension completely

posted by karev 8 years ago

You can get the extension from the fFile object, you just need to assign it to a variable first:

$file = new fUpload();
$dir  = new fDirectory($_SERVER['DOCUMENT_ROOT'].'/'.FOLDER.'/files');
$file = $file->move($dir, 'file_name');
$file = $file->rename('my_new_filename.' . $file->getExtension());
posted by wbond 8 years ago