This topic is locked

Rename uploaded single file (basic upload control)

9/10/2022 6:20:28 PM
PHPRunner General questions
A
alfonso authorDevClub member

I see this article valid for several files https://xlinesoft.com/phprunner/docs/rename_uploaded_file.htm
My question is how can I rename a single file, not an array of files?
Thanks

A
alfonso authorDevClub member 9/11/2022

I try in Edit page: Before record updated with this code, for example:

$filename = $values["my_file"];
$newFileName = "my_name.pdf";

rename($filename, getabspath($newFileName));:

what's wrong?

Sergey Kornilov admin 9/12/2022

You need to tell us us what is wrong. What doesn't work? What error messages you getting?

A
alfonso authorDevClub member 9/12/2022

In Before Record updated I write:

$filename = "../ficheros/curriculum/".$values['curriculum'];

curriculum is the field I use to save single upload file

$newFileName = "../ficheros/curriculum/".$values["nif"]."-".$values["nombre"]."-".strtoupper($values["apellidos"]).".pdf";

rename($filename, $newFileName);

With this code I get to change the display name of the uploaded file
$values["curriculum"] = $values["nif"]."-".$values["nombre"]."-".strtoupper($values["apellidos"]).".pdf";

With this code I can't change the file name

Sergey Kornilov admin 9/13/2022

You really need to read questions one more time and provide exact answers.

A
alfonso authorDevClub member 9/14/2022

I also try this code: https://xlinesoft.com/phprunner/docs/rename_uploaded_file.htm with limit 1 files
The first time I edit, everything is correct: change the display name and change the phisycal name
But if I edit again, delete the file and upload another file then no file is uploaded to the server although the display name does change