php - copy() function doesn't work

647

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 usingchmod 0777 but still it gives me same error

203

Answer

Solution:

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


What you need to do is give Apache the permission to write toC:/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.

871

Answer

Solution:

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";
  }
24

Answer

Solution:

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.

430

Answer

Solution:

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.

People are also looking for solutions to the problem: php - how to handle timeouts in getimagesize()

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.