Question about uploading a file

Ok, so I’ve been looking over my php code over and over but keep getting the same error: “There was an error uploading the file, please try again!”. I have no idea why… everything looks golden. My guess is that the problem has to do with the target path, I dunno.

My form:

Choose a file to upload:

My php:[php][/php]
[php]<?php

$destination = '/Users/Ozzie/Sites/Project/upload/';
$destination = $destination.basename($_FILES['uploadedfile']['name']);
echo $destination;
echo "<br/>";

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $destination)) {
echo "The file ".basename( $_FILES['uploadedfile']['name']). 
" has been uploaded";
} else {
echo "There was an error uploading the file, please try again!";
}
echo "<br/>";
print_r($_FILES);

?>
[/php]

You need to use a relative path “…/mypath” “folder/another”, or a local root path “/var/www/httpdocs/” “C:\xampp\htdocs\project\folder”

The path you are using is a web root - paths starting with a ‘/’ are handled differently in PHP to browsers.

Sponsor our Newsletter | Privacy Policy | Terms of Service