Ok, I have read all over about how you must change the permissions on a directory, but now I'm confused. I understand that chmod should be 777 or etc....but I am using Windows XP. I have php that tries to upload a file and I keep getting the following error:
Warning: copy(c:\shareimages.jpg): failed to open stream: Permission denied in C:\Inetpub\wwwroot\web\up.php on line 26
upload failed!
I dont know how to give the directory permissions. Can someone treat me like an idiot and tell me step for step on how to set the permissions? I am testing all of this locally, so there is no ftp involved. I simply want to move a file from one directory to another...simulating this happening over the web.
Heres the code:
<FORM ENCTYPE="multipart/form-data" ACTION="up.php" METHOD="POST">
The file: <INPUT TYPE="file" NAME="userfile">
<INPUT TYPE="submit" VALUE="Upload">
</FORM>
<?php
$path = "c:\share";
$max_size = 200000;
if (!isset($HTTP_POST_FILES['userfile'])) exit;
if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) {
if ($HTTP_POST_FILES['userfile']['size']>$max_size) { echo "The file is too big<br>\n"; exit; }
if (($HTTP_POST_FILES['userfile']['type']=="image/gif") || ($HTTP_POST_FILES['userfile']['type']=="image/pjpeg") || ($HTTP_POST_FILES['userfile']['type']=="image/jpeg")) {
if (file_exists($path . $HTTP_POST_FILES['userfile']['name'])) { echo "The file already exists<br>\n"; exit; }
$res = copy($HTTP_POST_FILES['userfile']['tmp_name'], $path .
$HTTP_POST_FILES['userfile']['name']);
if (!$res) { echo "upload failed!<br>\n"; exit; } else { echo "upload sucessful<br>\n"; }
echo "File Name: ".$HTTP_POST_FILES['userfile']['name']."<br>\n";
echo "File Size: ".$HTTP_POST_FILES['userfile']['size']." bytes<br>\n";
echo "File Type: ".$HTTP_POST_FILES['userfile']['type']."<br>\n";
} else { echo "Wrong file type<br>\n"; exit; }
}
?>