Posted by:
bsherwood
(---.hsd1.md.comcast.net)
I have Wamp 2.5 installed on a Windows Vista Home Premium machine. I am running into problems when trying to use the php function my_uploaded_file
Form code: (upload_form.php)
<html>
<head>
<title>File Upload Form</title>
</head>
<body>
This form allows you to upload a file to the server.<br>
<form enctype="multipart/form-data" action="upload.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="524288" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>
</body>
</html>
upload.php:
<?php
$max_filesize = 524288; // Maximum filesize in BYTES (currently 0.5M
.
// Where the file is going to be placed
$target_path = "C:". DIRECTORY_SEPARATOR. "wamp". DIRECTORY_SEPARATOR. "www". DIRECTORY_SEPARATOR. "uploads". DIRECTORY_SEPARATOR;
//echo $target_path;
/* Add the original filename to our target path.
Result is "uploads/filename.extension" */
$target_path = $target_path .
basename( $_FILES['uploadedfile']['name']);
$filename = $_FILES['uploadedfile']['name']; // Get the name of the file (including file extension).
if(filesize($_FILES['uploadedfile']['tmp_name']) > $max_filesize)
die('The file you attempted to upload is too large.'); // if we upload large file then we get error.
if(move_uploaded_file($_FILES['uploadedfile']['name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
// header ('location: whereeveryouwantogo.php')
} else{
if(!is_writable($target_path)){
die('You cannot upload to the specified directory'); // if we have no enough permission then got error.
}
echo "file not uploaded debug info follows".
print_r($_FILES);
}
?>
I get the message "You cannot upload to the specified directory" I have given full permissions to "Everyone" for the uploads folder. I also have messed around with the attrib command and currently have
attrib uploads
return
S C:\wamp\www\uploads
I think it has something to do with the file permissions with Vista, but I'm out of ideas. Any help really appreciated.
Thanks!
Edited 1 time(s). Last edit at 07/05/2014 06:41PM by bsherwood.