...

View Full Version : PHP file upload on windows server



sweenster
07-06-2005, 11:49 PM
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?

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

i.e.

c://folder/file.ext


but im not sure, never really used win server

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



if(is_uploaded_file($_FILES['form_image']['tmp_name']))
{
// 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>');
}
else
{
print ('<p class="bl"><strong>Unable to upload file.</strong></p><p>');
print_r($_FILES);
print('</p>');
}

delinear
07-07-2005, 09: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