WordPress.org

Ready to get started?Download WordPress

Forums

Cannot upload images ("No such file or directory") (37 posts)

  1. henderson1977
    Member
    Posted 6 years ago #

    Dear all - I have searched this forum but cannot find the answer I need.

    When I try to upload images I get the following error:-

    ----------------
    Warning: getimagesize(/share/HDA_DATA/Qweb/share/blog/wp-content/uploads/2008/03/dscf0001.JPG) [function.getimagesize]: failed to open stream: No such file or directory in /share/HDA_DATA/Qweb/share/blog/wp-admin/includes/image.php on line 143

    Warning: Cannot modify header information - headers already sent by (output started at /share/HDA_DATA/Qweb/share/blog/wp-admin/includes/image.php:143) in /share/HDA_DATA/Qweb/share/blog/wp-includes/pluggable.php on line 390
    ----------------

    I have tried resizing the images (JPG) and tried GIFs too, but no joy, I still get the error.

    What is the fix please?

    Thanks
    Scott

  2. kmessinger
    Volunteer Moderator
    Posted 6 years ago #

    It has nothing to do with the size.

    No such file or directory This file, dscf0001.JPG, is not where it is supposed to be.

  3. henderson1977
    Member
    Posted 6 years ago #

    Thanks for the reply, kmessinger.

    I am new to WordPress and only installed it for the 1st time recently. I can post messages but I cannot upload any images.

    I am simply trying to upload any image, regardless of size, from my desktop but I have always got this error.

    I am going wrong somewhere please?

    Regards
    Scott

  4. kmessinger
    Volunteer Moderator
    Posted 6 years ago #

    The headers part of the error normally means there is an extra line at the beginning or at the end of a file. Check image.php for any white space or a line before <? or after ?>.

  5. henderson1977
    Member
    Posted 6 years ago #

    Forgot to mention I did have a good look at many posts in this forum and followed advice to check for white space, which I have corrected in some files, including image.php and pluggable.php.

    I am surprised that having just installed WordPress, I would have to manually remove white space from PHP files just to get uploads to work.

    Any other ideas please?

  6. whooami
    Member
    Posted 6 years ago #

    actually. that headers error doesnt mean that. What it means is that output is being sent to the browser when it shouldnt be (its just typically seen in editing files improperly) -- in this case its caused by the error in uploading.. the error message itself is causing the headers problem.

    Focus on the upload issue -- thats the problem..

    Henderson, have you verified that you actually have the ability to upload files?

    Create a phpinfo.php file:

    <?php phpinfo(); ?>

    Upload that to your web space, and then open it in a browser.

    Look for this:

    file_uploads

    There will be a 1 or a 0 after it

    true = 1
    false = 0

    If its a 0 thats your problem.

  7. kmessinger
    Volunteer Moderator
    Posted 6 years ago #

    Normally that problem is with wp-config and not files that no one opens but since you opened and did change some files perhaps an error was introduced.

    Did you try deleting the files and then reuploading them?

    Another thing. Can you upload a file with FTP to wp-content/uploads/2008/03/ this directory? Are your permalinks set to default?

  8. henderson1977
    Member
    Posted 6 years ago #

    Thanks both.

    I don't know what permalinks are, so I guess there are default.

    I will try FTP (WSFTP ok?) and let you know.

    Scott

  9. whooami
    Member
    Posted 6 years ago #

    an even better test to narrow down whether or not its you files or a server issue, is to just try to upload outside of WP using a php script.

    here is a very basic upload script that will test whether or not you can even do php uploads -- the only diff is that this will use a directory on your site and not what the server is specifying in the global php.ini:

    <?php
    $filepath = "";
    ($_POST['Submit'] != "") {
    	$filename = $_FILES['image']['name'];
    	$file = $_FILES['image']['tmp_name'];
    		if (!(file_exists("$filepath$filename")))
    			{
    		$savedfile = @copy("$file", "$filepath$filename");
    		}
    		if ($savedfile)
    			{
    			echo "File has been uploaded..<br><br>";
    			}
    		else
    			{
    			echo "This file has not been uploaded..!";
    			}
    		}
    echo '<form method="post" action="upload.php"><input name="image" type="file" size="20"><br> <br><input type="submit" name="Submit" value="Upload!" size="20"></form>';

    ?>

    If you copy and paste that into a file named upload.php, put it in its own directory and chmod that directory to 777 you ought to be able to upload ANY file using that. If you cant...

    And actually, that might even use the /tmp dir as well so its an even better test. I should ssh in and watch :)

  10. henderson1977
    Member
    Posted 6 years ago #

    I have created upload.php and put it in a new folder called "uploads" on my desktop.

    Pardon my ignorance, but how do I initiate an upload please?

    Thanks for your help so far
    Scott

  11. whooami
    Member
    Posted 6 years ago #

    it needs to go on your site. and then you open it on your browser,, just like any other file you put there. :)

  12. henderson1977
    Member
    Posted 6 years ago #

    Of course! Oops!

    Well, I have copied to my website and browsed to http://www.domain.name/blog/uploads/upload.php but I get:-

    Parse error: syntax error, unexpected '{' in /share/HDA_DATA/Qweb/website/blog/uploads/upload.php on line 4

    Line 4 in upload.php is:-

    ($_POST['Submit'] != "") {

    Where to go from here please?

  13. whooami
    Member
    Posted 6 years ago #

    thats an issue with your copying and pasting..

    Just go grab this,

    http://www.village-idiot.org/broke/upload.txt

    download that, rename it to upload.php, and replace the one you copied and pasted.

  14. henderson1977
    Member
    Posted 6 years ago #

    I followed your instructions and "File has been uploaded successfully!"

    So does that mean there is a problem with my WP installation? If so, what is the best thing I should do please?

    Scott

  15. henderson1977
    Member
    Posted 6 years ago #

    Do I just need to replace wp-config.php from the original installation files please?

  16. kmessinger
    Volunteer Moderator
    Posted 6 years ago #

    When you sent the WP files, you should have received the same message. If not, you probably want to upload them again.

    If you want you can just upload your wp-config file (if you made changes to it) and see what happens. The important thing is now we know you can upload successfully.

    whooami, who I don't think is logged on yet, may have a different approach.

  17. henderson1977
    Member
    Posted 6 years ago #

    Just realised I shouldn't need to reinstate the original wp-config.php file because it contains my connection/database settings, etc... and I've already checked there's no whitespace before or after the php code.

  18. henderson1977
    Member
    Posted 6 years ago #

    I backed up the wordpress folder then replaced the server copy with the original wordpress folder. I tried to run upgrade.php and got...

    "No Upgrade Required. Your WordPress database is already up-to-date!"

    So I tried to run install.php but got...

    "Already Installed. You appear to have already installed WordPress. To reinstall please clear your old database tables first."

    I tried to upload images and still get the original errors (on first post). I have replaced the installation files and I still have the problem but using whooami's php script I proved uploading images DOES work, so what do I need to do? Delete the database? If so, how please? But would a faulty database prevent the upload of images anyway?

  19. henderson1977
    Member
    Posted 6 years ago #

    Even when I installed and activated the Yet Another Photoblog (YAPB) Plugin and tried to upload a JPG I got a similar error message:-

    ----------------
    Warning: getimagesize(/share/HDA_DATA/Qweb/website/blog/wp-content/uploads/2008/03/img_2228.jpg) [function.getimagesize]: failed to open stream: No such file or directory in /share/HDA_DATA/Qweb/website/blog/wp-content/plugins/yet-another-photoblog/lib/YapbImage.class.php on line 438
    ----------------

    Again, there is no whitespace at the beginning or end of YapbImage.class.php.

    There must be a fix for this problem?

  20. kmessinger
    Volunteer Moderator
    Posted 6 years ago #

    For problems with the plugin yapb, go to the authors site. He has a support forum and is pretty good about helping.

  21. henderson1977
    Member
    Posted 6 years ago #

    It may very well be a similar problem with YAPB, but it appears too coincidental considering the nature of problem is yet again uploading images.

    I merely installed YAPB to see if I could upload images by any other means, but no such luck.

    YAPB must use the same upload engine as WP, otherwise I may have to wipe my database tables and start from scratch.

    What do you think please?

  22. henderson1977
    Member
    Posted 6 years ago #

    I've had a look on http://johannes.jarolim.com/blog/wordpress/yet-another-photoblog/ but cannot find a support forum, can you point me in the right direction please?

  23. henderson1977
    Member
    Posted 6 years ago #

    ok,ok, I found it http://johannes.jarolim.com/yapb-forum/. Hopefully, I'll get to the bottom of this problem soon :o/

  24. henderson1977
    Member
    Posted 6 years ago #

    I used WinSCP to connect to Apache root and discovered that HDA_DATA change date = 06-Feb-2008 and there are 3 JPGs in /share/HDA_DATA/QWeb/website/blog/wp-content/uploads/2008/03 so it has successfully uploaded 3 images. However, it fails much more often than not.

    Perhaps incorrect folder permissions are causing this issue? I have checked that /share/HDA_DATA/QWeb/website/blog/wp-content/uploads is owned by guest and rights = 777.

    Also, within /share there is a "HDA_DATA" folder for each letter of the alphabet, i.e. HDA_DATA, HDB_DATA, HDC_DATA, HDD_DATA, HDE_DATA, and so on... Except HDA_DATA, every folder is empty, owned by admin, rights = 777 and change date = 07-Dec-2005.

    Is this normal?

  25. kmessinger
    Volunteer Moderator
    Posted 6 years ago #

    I don't understand the file system on your shared server. You show this: /share/HDA_DATA/QWeb/website/blog/ then this in the error message: No such file or directory in share/HDA_DATA/Qweb/share/blog/ which would be true. It is looking in the wrong place. Your website should be before blog.

    To me it looks like HDA_DATA is not owned by you. Anything above your website should basically be off limits.

    Anyway, to get you going, you can create a folder wp-content/uploads/2008/03/. Using FTP upload your images to this folder. Then use the "insert picture" icon or if you are using code mode, use code to insert the image.

    I keep my images (which are 644) in a folder called photos and it is 755. Your uploads folder should not be 777 AFAIK.

  26. henderson1977
    Member
    Posted 6 years ago #

    kmessinger

    I made a typo when editing my domain name to "website", it should read /share/HDA_DATA/QWeb/website/blog/, so the error message is "No such file or directory in share/HDA_DATA/Qweb/website/blog/.

    Following your instructions:-

    1) I checked the folder wp-content/uploads/2008/03/ is already created, so moving on the next step
    2) I used WinSCP to upload (copy) 3 new JPGs
    3) Then used "insert picture" icon to insert the images into a new post and it updated my site fine.

    Although, what does this prove? How can subscribers upload their own images to my blog please?

  27. kmessinger
    Volunteer Moderator
    Posted 6 years ago #

    Doesn't prove anything. I just wanted you to be able to at least get some images posted.

    What is your url? What are the permissions on these folders uploads / 2008 / 03 ?

  28. kjetilgf
    Member
    Posted 6 years ago #

    Hi
    Sorry if I missed something crucial, but I've got similar errors because of two mistakes:
    - The upload/etc folder didn't exist, had to create it manually (via FTP) - which you have done(?) (By the way, ftp is a MUST to know to use WP)
    - The permissions to the folder was set incorrectly.
    So, set its permissions to 777 and try again. Done that?

    To your last question, I believe that only depends on what role you give your users - though I haven't tried it myself yet.

    Kjetil

  29. henderson1977
    Member
    Posted 6 years ago #

    kmessinger, when I checked the folder permissions for uploads/2008/03 using WinSCP it shows as 777 and guest is "owner". Is there a better way to check?

  30. kjetilgf
    Member
    Posted 6 years ago #

    If you have the same owner on the other folders, "guest" should be OK. Use the other (and parent) folders'permissions as refference.

Topic Closed

This topic has been closed to new replies.

About this Topic