Mon. - Fri. 9 am - 5 pm Ask a Question
Remember me

Uploaded file filename

4 years 4 months ago #1

  • Zsolt's Avatar
  • Zsolt
  • Posts: 2
Hello,

is there any way to rename the uploaded file with the sender name or email. I've found this function:

$newFile = rand(666666, 666666666666). '_' .$_FILES[$fileName][$i];

And i want to add the name of a sender, not the rand number.

Thank you

4 years 4 months ago #2

  • Artem's Avatar
  • Artem
  • Posts: 8830
Hi,

Replace code to this
if (isset($_POST[1])) {
    $newFile = $_POST[1]. '_' .$_FILES[$fileName]['name'][$i];
         } else {
             $newFile = rand(666666, 666666666666). '_' .$_FILES[$fileName]['name'][$i];
          }

Where $_POST[1] it's ID of Field,


Replace 1 to your field ID

Regards,

4 years 4 months ago #3

  • Zsolt's Avatar
  • Zsolt
  • Posts: 2
Yippppi :) it works..

thank you!
have a nice day!
Powered by Kunena Forum