Why doesnt this file upload script work? (SPOT THE ERROR)
Posted: Sat Nov 11, 2006 9:26 am
feyd | Please use
THE PROBLEM: Yes the renamed file uploads but not to the specified folder (Uploads). Instead the file uploads to the main folder with the name (Uploads9898smile.jpg) instead of what i want (9898smile.jpg). I don't know why it adds the word Uploads to each uploaded file and why it doesnt go in the Upload folder.
(BTW: The actual uplaod form definatly isnt the problem i have checked)
Please help
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Why doesnt this file uplaod script work? PHP (SPOT THE ERROR)?
This is the script that is on the second page (upp2.php) ERROR EXPLAINED BELOW SCRIPT:Code: Select all
<?php
$file_name = $HTTP_POST_FILES['ufile']['name'];
$random_digit=rand(0000,9999);
$new_file_name=$random_digit.$file_name;
//for example upload file name cartoon.gif . $path will be upload/cartoon.gif
$path= "/home/content/t/n/i/tnine8MsoP29il/html/Uploads".$new_file_name;
if($ufile !=none)
{
if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path))
{
echo "Successful<BR/>";
echo "File Name :".$new_file_name."<BR/>";
echo "File Size :".$HTTP_POST_FILES['ufile']['size']."<BR/>";
echo "File Type :".$HTTP_POST_FILES['ufile']['type']."<BR/>";
}
else
{
echo "Error";
}
}
?>(BTW: The actual uplaod form definatly isnt the problem i have checked)
Please help
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]