Novahq.net Forum

Novahq.net Forum (https://novahq.net/forum/index.php)
-   phphq.Net Forums (https://novahq.net/forum/forumdisplay.php?f=277)
-   -   Adjusting File Name - phuploader (https://novahq.net/forum/showthread.php?t=46675)

AQucsaijr 05-17-2012 08:03 AM

Adjusting File Name - phuploader
 
What would I change in the code to have the random file also include the original file name?

example:
Upload file - filename.txt
Random File name saved to server: filename.62738939.txt

Is that possible? It would just make it easier for me to remember what the files were that were uploaded without having to open them up to figure it out.

Thanks

Scott 05-17-2012 08:38 AM

Change line 219 from
PHP Code:

$file_name[$i]=time()+rand(0,100000); 

to
PHP Code:

$file_name[$i]=strstr($_FILES['file']['name'][$i], '.'true).".".time()+rand(0,100000); 


AQucsaijr 05-17-2012 08:52 AM

Thank you Scott

AQucsaijr 05-17-2012 09:24 AM

This did not work for me Scott. I replaced the line of code but I still just get the random number for the file name. Dose it matter if the file names have spaces in the name?

Scott 05-17-2012 09:38 AM

I overlooked some brackets.. Try this line:

PHP Code:

$file_name[$i]=strstr($_FILES['file']['name'][$i], '.'true).".".(time()+rand(0,100000)); 


AQucsaijr 05-17-2012 09:56 AM

Perfect! Thank you Scott.


All times are GMT -5. The time now is 05:56 AM.

Powered by vBulletin®