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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-08-2008, 06:22 PM
chrbar is offline chrbar
Registered User

Join Date: Jul 2008
Posts: 2

phUploader can erase file?

Hello,

This script could be perfect for us, but we need to be able to upload existing file, to replace current file by a new version (same filename)!

Is it possible?

I would like to allow to someone of our community to update a PDF file on our Web site.
This script sounds good for that, I've tried it, but I obtain an error message if the file (filename) is already in the "uploads" folder.

Do you know if it's possible to do that with this script?

Thanks,
Chris
Reply With Quote
  #2  
Old 09-06-2008, 11:47 AM
ironmine is offline ironmine
Registered User

Join Date: Sep 2008
Posts: 2

Hi, I need this exact same thing and I can't figure out how to change the script to do it. Anyone know? Probably pretty simple, but I'm not that good with PHP...

Thanks for any answers, ironmine
Reply With Quote
  #3  
Old 09-06-2008, 12:57 PM
ironmine is offline ironmine
Registered User

Join Date: Sep 2008
Posts: 2

I just figured out something that works to allow files to be overwritten. It might be the wrong way to go about enabling that, if so would someone let me know? What I did was comment out two lines of code in the script, just look for the following and add the forward slashes as I did for two lines of code after the "Check if the file..." comment/note. Do this AFTER you change the variable that causes files to be written with random names to the one that specifies using the chosen name:

// Check if the file already exists on the server..
// } Elseif(file_exists($folder.$file_name[$i])) {

// $error.= "The file: ".$_FILES['file']['name'][$i]." exists on this server, please rename your file.<br />Your file(s) were <b>not</b> uploaded.<br />";

I don't know if this causes any security issues or whatever, but I'm using the script for private use so I'm not that concerned about secuirty...

ironmine
Reply With Quote
  #4  
Old 09-06-2008, 05:05 PM
Scott is offline Scott
Scott's Avatar
AKA. Panther

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

you could just use the above code, comment out the line that starts with $error.="The File... and add this line right below it:
PHP Code:
unlink($folder.$file_name[$i]); 
It would look something like this:
PHP Code:
// Check if the file already exists on the server..
} Elseif(file_exists($folder.$file_name[$i])) {

// $error.= "The file: ".$_FILES['file']['name'][$i]." exists on this server, please rename your file.<br />Your file(s) were <b>not</b> uploaded.<br />";
unlink($folder.$file_name[$i]); 
__________________

04' Dodge SRT-4, Mopar Stage 3, 406whp/436wtq
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to erase Linux partition from PC? carvercasey Hardware and Software 1 02-01-2010 06:07 AM
PhUploader problem buggerwepisspoo phphq.Net Forums 0 09-21-2008 06:18 PM
phUploader File Upload Vulnerability gopat phphq.Net Forums 7 05-27-2008 12:55 PM
phUploader sof-com phphq.Net Forums 1 05-25-2008 02:50 AM
phUploader help lodupersempre phphq.Net Forums 0 05-12-2008 08:30 AM


All times are GMT -5. The time now is 01:07 AM.




Powered by vBulletin®