Jump to content

File Upload To Windows Server Help


JackW

Recommended Posts

I have several sites on Linux servers where I have set it up so the site owner can upload picture files. Below is a simplified version of the code used. (without security features that are on the real sites.)Now I have a client that would like this feature on his site, but it is hosted on a windows server. The code does not work on his site.Html form Page code:

<body><form enctype="multipart/form-data" action="upload.php" method="POST">Please choose a file: <input name="uploaded" type="file" /><br /><input type="submit" value="Upload" /></form></body>

Php page code:

<body><?php$target = "upload/"; $target = $target . basename( $_FILES['uploaded']['name']) ; $ok=1; if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) {echo "The file ". basename( $_FILES['uploaded']['name']). " has been uploaded";} else {echo "Sorry, there was a problem uploading your file.";}?></body>

The html code is in a folder named test. That same folder named test contains a folder named upload. I set up the windows hosted site and one of my linux hosted sites exactly the same. On the linux server I get this message: “The file 100_0095.jpg has been uploaded” and the file is in the folder.On the windows server, no file in folder, and I get this message:“Warning: move_uploaded_file(upload/100_0095.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in D:\Hosting\5310323\html\test\upload.php on line 19Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'D:\Temp\php\php6435.tmp' to 'upload/100_0095.jpg' in D:\Hosting\5310323\html\test\upload.php on line 19Sorry, there was a problem uploading your file.”I have been looking for solutions and trying different things for 2 days. What am I doing wrong.Some one suggested it was a CHMOD problem. That is not the case on Linux. I don't have a clue about permissions on Windows. This is my first and I hope last experience with a windows server.Thank you for any help you can give.Is it possible to upload files to windows servers and how is it done?

Link to comment
Share on other sites

It's just a permission error with the directory you're trying to move the file to:Warning: move_uploaded_file(upload/100_0095.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in D:\Hosting\5310323\html\test\upload.php on line 19You need to find the directory on the server, right-click on the directory and choose Properties, then the Security tab. In the list of users look for the anonymous internet user account, it starts with "IUSR_" and then has the computer name. You need to give that account write and modify access to the directory.

Link to comment
Share on other sites

It's just a permission error with the directory you're trying to move the file to:~ ~ ~You need to give that account write and modify access to the directory.
Thank you! Thank you! Thank you! That Worked! I can't believe the number of hours I spent trying to find the answer because I was too stuborn to ask for help.Have a Merry ChristmasJackW
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...