copy() function doesn't work

﹥>﹥吖頭↗ 提交于 2019-12-10 22:57:10

问题


I have task to copy my file from a folder to the current one. But when I perform this I get the following error:

Warning:  copy(C:/wamp/www/dfms/) [function.copy]: failed to open stream:
Permission denied in C:\wamp\www\dfms\docShow.php on line 646

The code is given below

if (copy('images/uploads/'.$doclisting['docfile_name'], 'C:/wamp/www/dfms/'))
{
  echo "Pranav";
}

I also tried by using chmod 0777 but still it gives me same error


回答1:


Have you tried adding the filename to the destination?

Like so:

if(copy('images/uploads/'.$doclisting['docfile_name'],'C:/wamp/www/dfms/'.$doclisting['docfile_name']))
  {
    echo "Pranav";
  }



回答2:


You are on a windows server, which means that chmod 0777 will probably not do much.


What you need to do is give Apache the permission to write to C:/wamp/www/dfms/ -- doing so the windows way.

Not sure about a Windows server, but I'm guessing right-clicking on that directory, choosing Properties, findind some "permission" or "security" tab, and checking some checkbox that corresponds to "write" for the correct user should do the trick.




回答3:


chmod 0777 is a unix command, I'd be curious how you successfully tried this on windows.

Check these file and directory access control. You should make sure that the webserver process/user has the rights to this directory.




回答4:


Make sure you have "allow_url_fopen = On" in your php.ini

The php.ini file is where you declare changes to your PHP settings. You can edit the existing php.ini, or create a new text file in any subdirectory and name it php.ini.



来源:https://stackoverflow.com/questions/5272233/copy-function-doesnt-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!