how to upload large file to DB

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
freeAngel_007
Forum Newbie
Posts: 9
Joined: Thu Jun 19, 2008 12:23 pm

how to upload large file to DB

Post by freeAngel_007 »

Hi guys,

I hope i am in right topic :drunk:

Ok I have a problem with picture uploading.

I have a working HTML form and PHP script which is uploading the file to MySql. But the problem is if i want upload picture with more than 2MB it don`t Work. Is there any way how I can resize and make it smaller that picture on clients side?

I am wondering if it can do JavaScript and then send resized picture to PHP script?
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Re: how to upload large file to DB

Post by hawleyjr »

Are you storing the image in the database? If so, don't. Store it in a directory and reference the physical file to the database.
User avatar
w35z0r
Forum Newbie
Posts: 17
Joined: Thu May 18, 2006 7:02 pm

Re: how to upload large file to DB

Post by w35z0r »

And if your going to do that, you might want to check your php.ini file for these lines

Code: Select all

post_max_size = **some number, by default it will be 2M**
upload_max_filesize = **some number, by default it will be 2M**
 
All you have to do is change that to something more appealing, and you're good to go ... I think...
WebbieDave
Forum Contributor
Posts: 213
Joined: Sun Jul 15, 2007 7:07 am

Re: how to upload large file to DB

Post by WebbieDave »

freeAngel_007 wrote:Is there any way how I can resize and make it smaller that picture on clients side?
No (unless you want to write a browser-plugin and make everyone install it, :))

Try the above suggested configuration changes and also have a look at this thread for some more config changes you may need:
viewtopic.php?f=1&t=84366
nowaydown1
Forum Contributor
Posts: 169
Joined: Sun Apr 27, 2008 1:22 am

Re: how to upload large file to DB

Post by nowaydown1 »

Is there any way how I can resize and make it smaller that picture on clients side?
If your purpose for attempting to do so is to reduce downstream filesizes/image sizes, then sure it can be done. You can use either ImageMagick or GD if your PHP installation has those extensions enabled. Its easy enough to generate a smaller version of an image file.
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Re: how to upload large file to DB

Post by Zoxive »

WebbieDave wrote:
freeAngel_007 wrote:Is there any way how I can resize and make it smaller that picture on clients side?
No (unless you want to write a browser-plugin and make everyone install it, :))

Try the above suggested configuration changes and also have a look at this thread for some more config changes you may need:
viewtopic.php?f=1&t=84366
You don't need a browser-plugin. There are already websites that have this (Facebook as an example), they usually use Java. (Which still requires browser plugin, but Java's not your own custom).
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Re: how to upload large file to DB

Post by jayshields »

Zoxive wrote:There are already websites that have this (Facebook as an example), they usually use Java. (Which still requires browser plugin, but Java's not your own custom).
Wait... Facebook's image upload applet resizes images before it uploads it to the web server?
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Re: how to upload large file to DB

Post by Zoxive »

jayshields wrote:Wait... Facebook's image upload applet resizes images before it uploads it to the web server?
Yes, i know for a fact it does. I'm sure it doesn't do all the resizing locally, but it does decrease the file size some way with Java, and then sends the image data to the server.
Post Reply