Cannot upload pictures

jayp

Joined: 2005-10-24
Posts: 52
Posted: Sat, 2009-06-27 15:10

Let me say that I think I like what I see in G3 a lot. It appears to be such a big improvement for its interface and intuitiveness from G2 that I have high hopes. (I'll have to see how easy it really is to modify and theme.)

I just installed beta1 for the first time and I'm having fits trying to upload pictures. At first, I got the "upload error 406" message after trying to upload. After lots of searching, I added the following to my .htaccess:

Quote:
<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>

This then changed the error message to "upload error 500". This really took a long time to make any progress, but I finally got rid of this error by modifying the ownership of the var folder. Changing ownership of all sub-directories and files to the local user or nobody got rid of the error. Previously, var was owned by root since that's the user I created var with. Is this is an openbase_dir problem? I think (but am not certain) that openbase_dir is enabled on my server.

So after all that, uploads give no errors in the interface but the images apparently aren't getting uploaded. The record shows up in the database and album, but the image is missing. I also can't find any files inside var. I can't see any sub-folders in var/albums. I've also tried using both Imagemagick and GD, and I tried manually changing the path to the image library as described in a few other threads.

Each time I try to upload a picture, the log records this:

Quote:
2009-06-26 20:00:53 -05:00 --- error: Uncaught Exception: @todo MALFORMED_INPUT_FILE in file modules/gallery/helpers/graphics.php on line 195

Any suggestions would be very appreciated.

I also think it would be great to either add the lines above to .htaccess if G3 is incompatible with mod_security, or better yet fix whatever is causing the 406 exception.

Also, some documentation on the ownerships and permissions that are excepted by G3 (perhaps at install when the user is prompted create the var folder) would be really nice.

I still wonder if my problem isn't an ownership / permissions problem inside var. (On my server, var itself is 777 and it's sub-directories are 755.)

I know that the development takes lots of work and that answering questions like this takes even more. I want to say THANK YOU for all the great work that's happening. I really look forward to seeing the final product and being able to test drive beta1 further if I can fix my problems.

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Sun, 2009-06-28 04:40

I've updated the default .htaccess file to contain those lines in this change. Hope that doesn't make things worse :-)

I'm guessing that we're still seeing some issues with mod_security, though. Under normal circumstances, when the webserver creates var, it has unlimited access inside it. Check the ownership of var. If it's owned by the webserver user, there should be no problems. If not, make all dirs under it 777 not 755.

For the most part, we're trying *really* hard to avoid inundating users with tons of technical info while still getting things working for most users.

---
Problems? Check gallery3/var/logs
bugs/feature req's | upgrade to the latest code | use git | help! vote!

 
jayp

Joined: 2005-10-24
Posts: 52
Posted: Sun, 2009-06-28 14:16

Hi bharat,

I change my var folder and all its files and subdirectories to 777. It still didn't work. I tried using both Imagemagick and GD. Same result. Uploads appear to work, but the image doesn't show up. I get the same error message in the logs:

Quote:
2009-06-28 08:41:22 -05:00 --- error: Uncaught Exception: @todo MALFORMED_INPUT_FILE in file modules/gallery/helpers/graphics.php on line 195

I'm sure I'm using the right user -- nobody -- because if I use root or the owner of the account, log files don't get written to. So I'm pretty sure php is running as nobody and can't create or edit files if they're not also owned by nobody.

I should also point out that I see no files from my upload anywhere in var. All the subdirs in var are empty: uploads, tmp, albums, thumbs. It's like the file's not really uploading even though the flash uploader gives me the complete message in green (making it look like uploading worked).

Is there anything else I can try or test to help troubleshoot? I think it would be great to at least understand why this is happening as others are bound to have the same problem.

Finally, I couldn't agree more with trying to make G3 as simple as possible (ie, not inundating users with technical info). Of course, if one can't upload pictures, simplicity is still not a virtue. :) I guess I'm advocating that if permissions or ownership of var is going to be an issue, then having a link somewhere to explain how permissions and ownership are supposed to be setup would be helpful. One might have a link on the upload screen that goes back to gallery's site with documentation. Something like this mockup:

[IMG]http://i672.photobucket.com/albums/vv86/jay-forums/g3-trouble-uploading.png[/IMG]

Or, a more ambitious but even better approach might be to have a help link or icon throughout the administrative screens of gallery. Clicking on the help link would send users to the documentation on the gallery site so that they can learn more about a topic.

Here's what the upload screen might look like with a help icon.

[IMG]http://i672.photobucket.com/albums/vv86/jay-forums/g3-upload-help-button.png[/IMG]

Here's an example of what the link might look like on a full admin page. Clicking the question mark icon would give information about the User Admin features of gallery.

[IMG]http://i672.photobucket.com/albums/vv86/jay-forums/g3-admin-help-button.png[/IMG]

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Sun, 2009-06-28 18:49

Great usability suggestions! I've forwarded them on to Chad and Jakob, hopefully we can get them into the product.

For your specific problem, I'm not sure what's going on. The best place to start is to get the latest code (see my upgrading link below) and reproduce the problem. Then let's start digging through the code to see why it thinks the file you're uploading is malformed. Possibly Apache is intercepting the file (check your Apache2 error logs for that). If Gallery3 is getting the file properly, then we can fix this in our code, but if Apache is mangling it in some way then it's something with your config (perhaps mod_security still).

---
Problems? Check gallery3/var/logs
bugs/feature req's | upgrade to the latest code | use git | help! vote!

 
jayp

Joined: 2005-10-24
Posts: 52
Posted: Sun, 2009-06-28 20:16

Ok. I'm now using the latest code. Problem still exists. So I looked at my Apache2 logs. The only thing I can see is the following:

Quote:
[Sun Jun 28 14:21:59 2009] [error] [client 74.xxx.x.xxx] File does not exist: /home/username/public_html/gallery/var/thumbs/Quick_Test/img_090611_1187.jpg

I can't see anything about mod_security in the error log. Further, looking at my logs for mod_security, I don't see anything other than the earlier 406 errors that occurred prior adding the exclusion in gallery's .htaccess file.

However, gallery's error logs now have different information that may help.

Quote:
2009-06-28 15:02:08 -05:00 --- error: Caught exception rebuilding image: img 080524 5857
@todo EMPTY_INPUT_FILE
#0 /home/username/public_html/gallery/modules/gallery/helpers/graphics.php(155): graphics_Core::resize('/home/username/...', '/home/username/...', Array)
#1 /home/username/public_html/gallery/modules/gallery/helpers/photo.php(111): graphics_Core::generate(Array, Array)
#2 /home/username/public_html/gallery/modules/gallery/controllers/simple_uploader.php(61): photo_Core::create(Object(Item_Model))
#3 [internal function]: Simple_Uploader_Controller->add_photo(Object(Item_Model), '/home/username/...', 'jpacker_080524_...', 'img 080524 ...')
#4 /home/username/public_html/gallery/system/core/Kohana.php(291): ReflectionMethod->invokeArgs('2')
#5 /home/username/public_html/gallery/system/core/Event.php(209): Kohana::instance(Object(Simple_Uploader_Controller), Array)
#6 /home/username/public_html/gallery/system/core/Bootstrap.php(55): Event::run()
#7 /home/username/public_html/gallery/index.php(85): require('/home/username/...')
#8 {main}

Let me know what to try next. Thanks!

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Tue, 2009-06-30 02:59

Ok, so the uploader hands off the file to the graphics code which bombs because the file is empty. Why is that I wonder? Try editing modules/gallery/controllers/simple_uploader.php and on line 61, comment out the call to unlink(). That'll leave the temporary file around. I'm guessing that when we look at the temporary file we're going to find that it really is a zero-byte file. Print out the contents of $_FILES. You'll want to do something like this:

        Kohana::log("alert",print_r($_FILES,1));

to dump it into the log file. What do you see there? It sounds to me like something upstream of PHP (ie, in Apache) is intercepting the file and mangling it in some way.
---
Problems? Check gallery3/var/logs
bugs/feature req's | upgrade to the latest code | use git | help! vote!

 
pande

Joined: 2005-05-08
Posts: 56
Posted: Tue, 2009-06-30 19:06

This sounds something like my problem as well. See http://gallery.menalto.com/node/88555. I have an @todo EMPTY_INPUT_FILE too... But, then again, since I gave ALL the folders under 'VAR' 777 permissions and my host increased the max upload size from 2 mb to 16 mb, I am able to upload single of multiple photo's using just the 'normal' Add Photos-button... It's just the server_add function that is not working for me... As it seems more people have that problem, I hope it can be fixed...

 
jayp

Joined: 2005-10-24
Posts: 52
Posted: Tue, 2009-06-30 22:01

Ok. Interestingly enough, I do NOT get an empty file in var/uploads. The picure is there, and downloading it with FTP, I can open it in every photo program I have, from Photoshop to Windows Photo Viewer.

I added the logging right after the ulink that I commented out. The results are:

Quote:
2009-06-30 16:38:28 -05:00 --- alert: Array
(
[Filedata] => Array
(
[name] => img_090611_1187.jpg
[type] => application/octet-stream
[tmp_name] => /tmp/phpzs7bN1
[error] => 0
[size] => 145425
)

)

Seeing where the tmp image was being put, I did take a look at the /tmp directory. It's 777 and owned by root. So I changed the ownership to nobody and to the local user that this g3 install is running under. Neither made a difference, as uploads still didn't show up.

As mentioned earlier, I also don't see anything in var/albums or var/thumbs. Could there be a problem someone writing to those directories?

Also, @pande, my problem does not appear to be the same as yours. I haven't mentioned adding pictures from the server (your problem), nor can I upload any pictures through the browser (which works for you).

For clarification, I can also say that my max upload size is 20 Mb. I also have multiple gallery2 installs on this server all running without any problems.

What comes next?

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Sun, 2009-07-12 16:54

Sorry.. I'm travelling for a month so my time for support has been limited. So the file is getting transferred, which is good news because it means that we can fix this. The next thing to do is to make sure that the file it specifies is actually there, so you can do:

Kohana::log("alert", `ls -al $_FILES['Filedata']['tmp_name']`);

I think that's right, haven't had a chance to test it. But basically at this point you should start stepping through simple_uploader.php and adding debug statements to try to narrow down where the failing is happening. I'd be especially curious to see if this line is succeeding:

      $temp_filename = upload::save("Filedata");

Somewhere along the line, that flie is getting blanked! Got to run.. but I'll check back later.
---
Problems? Check gallery3/var/logs
bugs/feature req's | upgrade to the latest code | use git | help! vote!

 
jayp

Joined: 2005-10-24
Posts: 52
Posted: Mon, 2009-09-14 19:35

Well, sorry to be so slow in replying myself. I was traveling for a month too and then dealing with the death of two close family members, two weeks apart. :(

At any rate, the problem no longer exists. I've just done a fresh install of G3 Beta3 and am now using Firefox 3.5 (with a slightly newer version of Flash too). So whatever it was has been fixed in the code or was a browser specific problem that no longer exists.

G3 is looking great. Thanks so much for the help.

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Tue, 2009-09-15 20:47

I think I stumbled upon this and fixed it about a month ago. Glad to hear that it's working for you@
---
Problems? Check gallery3/var/logs
bugs/feature req's | upgrade to the latest code | use git