View Full Version : PHP file upload on windows server

07-07-2005, 12:49 AM
I have a simple PHP file upload script that works fine on my UNIX server but when I try to run it on a windows server I get the following error message:

Warning: copy(D:\Inetpub\fsstrath\Live\upl\uploads) [function.copy]: failed to open stream: Permission denied in D:\Inetpub\fsstrath\Live\html\adm_fupload.php on line 6

IIS permissions for the directory are set.

I did a guick google and found out that for windows the path needs to be defined with double slashes - i.e D:\\Inetpub\\fsstrath\\Live\\upl\\uploads - but that didnt work.

Any ideas/suggestions on whats causing this?

07-07-2005, 05:44 AM
i thought it was only double slashes after the drive



but im not sure, never really used win server

07-07-2005, 09:46 AM
its ok... managed to figure it out. I stoped using copy and found a new function - move_uploaded_file:

// file uploaded to server
move_uploaded_file($_FILES['form_image']['tmp_name'], "D:\\Inetpub\\fsstrath\\Live\\upl\\uploads\\".$_FILES['form_image']['name']);

print ('<p class="bl"><strong>File is valid, and was successfully uploaded</strong></p>');
print ('<p>Link to the file at:<br/><a href="upl/uploads/'.$_FILES['form_image']['name'].'" target ="_blank">upl/uploads/'.$_FILES['form_image']['name'].'</a></p>');
print('<p><a href="_indax.php?page=fupload&data='.$data.'&cat=0">Upload Another File</a></p>');
print ('<p class="bl"><strong>Unable to upload file.</strong></p><p>');

07-07-2005, 10:59 AM
Yep, move_uploaded_file() is always a better option than copy(), since it's both open_basedir and safe_mode friendly the only thing you ever have to worry about is setting permissions on the directory you want to move the file to.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum