An odd error with an image upload script.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Sephern
Forum Commoner
Posts: 73
Joined: Sun Jan 04, 2009 4:44 pm

An odd error with an image upload script.

Post by Sephern »

First of all, apologies if I've posted this in the incorrect place. I wasn't too sure whether it was here or Theory and Design which would be most apt for my problem.

I've created an image upload form which base64 encodes the image, and then stores the base value in a SQL database. The image can then be referenced directly from a PHP script which decodes the base64, and sends the relevant HTTP header.

However, when uploading large files, the script doesn't work.

The database field size is sufficient, and it isn't cutting off the end of the image, it just seems to be failing to insert the row.
The image is being sent via post (obviously) and being encoded in the same script that includes it to the database, so url and http limitations aren't an issue.

Is there any notable limitation that would prevent large images being uploaded? I'm sure I've missed something obvious somewhere.

Thanks for the help ^_^
User avatar
flying_circus
Forum Regular
Posts: 732
Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR

Re: An odd error with an image upload script.

Post by flying_circus »

Hitting the script max execution time or max upload file size?
Sephern
Forum Commoner
Posts: 73
Joined: Sun Jan 04, 2009 4:44 pm

Re: An odd error with an image upload script.

Post by Sephern »

The max upload file size is 20mb, I was encountering issues at 1mb.

Script execution time is 30 seconds, and it finishes executing within that time. Specifically, it feeds back saying that it has uploaded and that the ID is 0 (meaning it clearly hasn't added the record).
User avatar
flying_circus
Forum Regular
Posts: 732
Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR

Re: An odd error with an image upload script.

Post by flying_circus »

Interesting, and mysql isnt reporting any errors either?

I realize its a crude test, but I'll typically echo the query string and try running it manually through MySql query browser.
Sephern
Forum Commoner
Posts: 73
Joined: Sun Jan 04, 2009 4:44 pm

Re: An odd error with an image upload script.

Post by Sephern »

Ah, it would appear the issue is the max_allowed_packets limitation on SQL.
User avatar
flying_circus
Forum Regular
Posts: 732
Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR

Re: An odd error with an image upload script.

Post by flying_circus »

Thanks for sharing the solution! I'll file that one away in the gotcha's list :)
Post Reply