0
votes

I've been stuck on this code for days as I am hitting this error when I upload a file to the server. Its a windows server running on Apache

Tried various solutions but still receiving the error. I tried changing full permissions to everyone on that server.

I changed the default PHP upload tmp file to inside my application yet I am still having this error.

Warning: move_uploaded_file(C:\My_Workspace\ojs2002) [function.move-uploaded-file]: failed to open stream: Permission denied in C:\My_Workspace\ojs\admin\include\fileupload.php on line 78

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\My_Workspace\ojs\tmp\phpCB78.tmp' to 'C:\My_Workspace\ojs2002' in C:\My_Workspace\ojs\admin\include\fileupload.php on line 78

 // copy the file, making the destination directory if necessary
 $filedir = 'C:/My_Workspace/ojs2002/'.basename($_FILES['articlefile']['name']);


 chmod($_FILES["articlefile"]["tmp_name"], 0777);
 chmod($filedir, 0777 );        

 move_uploaded_file($_FILES["articlefile"]["tmp_name"],$filedir);

The code would work fine on Linux servers but not on Windows.

Any help would be very much appreciated. Thank You.

2
sorry if I am misunderstanding, but have you changed the permissions of ojs2002 to 777?Austin

2 Answers

1
votes

I decided to switch from:

move_uploaded_file($uploaded_file, $file_path);

to

file_put_contents($file_path, file_get_contents($uploaded_file));
@unlink($uploaded_file);

The unlink might fail but I'm not too worried about that.

0
votes

chmod won't work on Windows, as it uses a different type of permission system. Make sure the user Apache runs as has full write access to the folder you're trying to move the files to (right click and click on sharing or permissions depending on the version of windows)