a4udi
01-15-2010, 02: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.
<?php
//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>";
}
else
{
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.
<?php
//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>";
}
else
{
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.