Go Back   Novahq.net Forum > phphq.Net > phphq.Net Forums

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-17-2012, 08:03 AM
AQucsaijr is offline AQucsaijr
Registered User

Join Date: May 2012
Posts: 4

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
Reply With Quote
  #2  
Old 05-17-2012, 08:38 AM
Scott is offline Scott
Scott's Avatar
AKA. Panther

Join Date: Sep 2001
Location: Minneapolis, MN
Posts: 10,919

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); 
__________________

04' Dodge SRT-4, Mopar Stage 3, 406whp/436wtq
Reply With Quote
  #3  
Old 05-17-2012, 08:52 AM
AQucsaijr is offline AQucsaijr
Registered User

Join Date: May 2012
Posts: 4

Thank you Scott
Reply With Quote
  #4  
Old 05-17-2012, 09:24 AM
AQucsaijr is offline AQucsaijr
Registered User

Join Date: May 2012
Posts: 4

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?
Reply With Quote
  #5  
Old 05-17-2012, 09:38 AM
Scott is offline Scott
Scott's Avatar
AKA. Panther

Join Date: Sep 2001
Location: Minneapolis, MN
Posts: 10,919

I overlooked some brackets.. Try this line:

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

04' Dodge SRT-4, Mopar Stage 3, 406whp/436wtq
Reply With Quote
  #6  
Old 05-17-2012, 09:56 AM
AQucsaijr is offline AQucsaijr
Registered User

Join Date: May 2012
Posts: 4

Perfect! Thank you Scott.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 04:59 PM.




Powered by vBulletin®