2013-08-20 19:05
浏览 56


I am getting an error while uploading images to my website host. But I don't experience any problems on my WAMP server. This is the error I am getting.

[20-Aug-2013 00:58:27 America/Denver] PHP Warning:  copy(/photos/Light-And-Snow.jpg) [<a href='function.copy'>function.copy</a>]: failed to open stream: No such file or directory in /home/rajeev/public_html/upload.php on line 86

The code on line 86 is

                "INSERT INTO
                    gallery_photos (
                ) VALUES(
                ) or die(mysql_error() . 'Photo not uploaded');

            $filetype = $photos_uploaded['type'][$counter];

            $extention = $known_photo_types[$filetype];

// Store the orignal file
copy($photos_uploaded['tmp_name'][$counter], $images_dir."/".$photos_uploaded['name'][$counter]);

What am I doing wrong? Thanks for any directions...

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dshun123456 2013-08-20 19:14

    It looks like you are trying to save the photos to /photos/ directory on your host. In a shared hosting environment, you will most likely not have access to create folders on the root of the filesystem.

    I'm guessing, you have a line somewhere like

    $images_dir = '/photos';

    You need to change this to a relative path instead of an absolute path:

    $images_dir = $_SERVER['DOCUMENT_ROOT'] . '/photos';

    You might also have to create that folder and make sure it has permissions for you to write. This can be done through the command line, if you have shell access, or through the admin tool your hosting provider supplies.

    It works on WAMP because you are liking running with relaxed permissions: Apache has permission to create or write to a C:\photos\ directory

    打赏 评论

相关推荐 更多相似问题