2
votes

php script for uploading file to mapped network drive is not working . Following are the php script:

$newfilename = "something.wav";
$path  = 'Y:\\uploaded\\'.$newfilename;
copy($_FILES['ufile']['tmp_name'], $path);

I have also check permission for network drive folder.I have Y drive mapped to the network drive(10.4.4.32) d drive within uploaded folder. It have full control permission. I have tried following path for network drive:

  • Y:\uploaded\
  • \\10.4.4.32\d$\uploaded\
  • move_uploaded_file($_FILES['ufile']['tmp_name'], $path);

But, It works on local drive like:

  • d:\uploaded\ The file is uploaded in local drive but could not uploaded in network drive. I have used php 5.3 and IIS 7 for application

Errors Showed: Warning: copy(\10.4.4.32\d$\uploaded\test.wav): failed to open stream: Permission denied in C:\inetpub\wwwroot\myapp\upload.php on line 107

I have allow permission of full control in the properties of the uploaded folder for EVERYONE user. Is there any other permission , I should fixed.

2
Have you already tried with move_uploaded_file()?HBv6
ya, I have just tried, not working..CodeManiac
"It does not work" - great explanation of your problem, I'm contacting Charles Xavier to help me figure out what "does not work" means for you.hakre
I explained that it is uploaded to the local drive but not in network drive and there isn't showing any error while file not uploaded....CodeManiac

2 Answers

0
votes

First, check if copy() returns false. This indicates that there is really an error.

Then, enable the track_errors directive in your php.ini, as well as display_errors and error_reporting to the highest level. When track_errors is activated (and you restarted your webserver), use the following line after the copy:

var_dump($php_errormsg, error_get_last());

This should give you a better hint about the problem.


Also make sure that if you're using safe_mode and open_basedir, the path you're moving to is allowed.

0
votes

network drive may not work for neither apache nor php , so use this $path = "\\machine-name\share_path\";

set up an user account on BOTH computer such as user : ApacheUser

go to services and click Apache , and use the account just created to logon (second tab) the Apache service of source computer

restart the apache service

then it should work now