PDA

View Full Version : PHP PHP file uploader not working



johnyct9760
September 10th, 2008, 03:48 PM
Hello and thx for reading my post. I can't get this PHP uploader to work
I followed the tutorial as closely as I could and something went wrong, here is a link to the test page:
http://www.johncliffordtaylor.com/upload2/
Every time I upload it say that the file didn't upload.
Here is a link to the tutorial I was following:
http://www.tizag.com/phpT/fileupload.php
And here is the PHP code that I ended up with I've looked it over for mistakes:

<?php
$target_path = "/johncliffordtaylor.com/upload2/uploads/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
$_FILES['uploadedfile']['tmp_name'];
$target_path = "/johncliffordtaylor.com/upload2/uploads/";
$target_path = $target_path . basename($_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target_path))
{
echo "The File". basename($_FILES['uploadedfile']['name']).
"has been uploaded";
}
else
{
echo "There was an error uploading your file please try again. And remember that all uploaded files need to be under 50 megs.";
}
?>
Any help would be greatly appreciated

tfg
September 11th, 2008, 07:09 AM
the paths to the files should be absolute paths from the filesystem's root.

that means on windows it would be something like d:\INETPUB\sites\johncliffordtaylor.com\upload2\up loads or on linux it would be something along the lines of /home/sites/johncliffordtaylor.com/upload2/uploads.

to find this out, create this following script, upload it and test in your browser. it'll be listed as either the DOCUMENT_ROOT or the SERVER_PATH (i can't remember which)


<?php

phpinfo():

?>

also, at the top of your script above add the line

error_reporting(E_ALL);

underneath your first <?php tag. i can't stress enough how much easier it is to debug a script when php is telling what's wrong with it rather than making blind changes and hoping for the best!