View Full Version : Upload Script not working / naming problem

01-15-2010, 03:54 PM
Hi, I downloaded a script (upload_ac) to upload a single file.. basically the idea is that the user can replace a .pdf weekly with the new version and just upload it with this form, but it doesn't seem to be working. Here is the code.


//in this example we keep file in folder upload
//$HTTP_POST_FILES['ufile']['name']; = upload file name
//for example upload file name cartoon.gif . $path will be upload/cartoon.gif
$path= "../folder/current-document.pdf".$HTTP_POST_FILES['ufile']['name'];
if($ufile !=none)
if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path))
echo "<center><font face='arial,helvetica,sans-serif' size='2' color='#002e62'><b>UPLOAD SUCCESSFUL</b></font></center>";

echo "Error";

The uploader works when I use the above, but it names the file wrong:
$path= "../folder/current-document.pdf".$HTTP_POST_FILES['ufile']['name'];

file ends up in the folder and being called "current-document.pdfcurrent-document.pdf"

when I make the path $path="../folder/".$HTTP_POST_FILES['ufile']['name'];
then the upload doesn't even work? Am I missing something.

01-15-2010, 04:33 PM
Try this to see if its any closer.

$path= "../folder/current-document$HTTP_POST_FILES['ufile']['name'].pdf";

Or another option

$path= "../folder/current-document".$HTTP_POST_FILES['ufile']['name'].".pdf";

01-15-2010, 05:14 PM
Use $_FILES instead of HTTP_POST_FILES I believe that http_post_files was depricated as of PHP 5.

Master of follies is almost right but you need to remove the .pdf from the end of the path because it is provided when you use the name value.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum