How to rename uploaded file?

139 views
Skip to first unread message

joshas

unread,
Jul 10, 2018, 1:42:28 PM7/10/18
to Fat-Free Framework
Hi,

I'm using receive() function from Web class to upload files. Is there a way to rename file before moving it to upload directory? I tried doing it in callback, but it is impossible to give file a new name. I'm trying to solve an issue, when file with identical name is uploaded and I must add suffix to it.
Found a post [1] from way back, but solution is not working with version 3.6 .

ved

unread,
Jul 10, 2018, 8:32:25 PM7/10/18
to Fat-Free Framework
Hi,

You should post the code in question.

Did you follow these instructions?

As stated on that page, it should be something like:

$files = $web->receive(function($file,$formFieldName){
		// ...
	},true,function($fileBaseName, $formFieldName){
		// build new file name from base name or input field name
		return "custom_filename.jpg";
	}
);

joshas

unread,
Jul 11, 2018, 12:51:19 PM7/11/18
to Fat-Free Framework
The problem with slug callback is that there's only file name available, not full upload path.

richgoldmd

unread,
Jul 11, 2018, 12:54:54 PM7/11/18
to Fat-Free Framework

The upload path is known, however- its set in the UPLOAD hive variable.

joshas

unread,
Jul 11, 2018, 12:56:02 PM7/11/18
to Fat-Free Framework
Of course, thanks.
Reply all
Reply to author
Forward
0 new messages