benjam Posted July 31, 2006 Share Posted July 31, 2006 I am trying to upload an image from an html form and then resize that image and save the image (not the filename, but the actual data) to a database.I can do it just fine by opening the file, reading the contents, and uploading the contents to the database, but when I try to resize the image (which I can also do just fine) and then try to read the contents of the GD resource, I cannot get the actual data back out in a string (binary) format to be saved in the database.So my question is this:How can I read the data from the resized image resource so that I can save it to the database?Thanks for any help. Quote Link to comment Share on other sites More sharing options...
Chetan Posted July 31, 2006 Share Posted July 31, 2006 thats difficult but caption ck would tell you how to do it without telling you the script1st Use the script to save the uploaded file somewhere2nd Create a page which uses the GET method to get the file name and it shows the image resized3rd The first script should get the contents of the 2nd script after giving it the get parameters (eg fread("image.php?url=uploads/pic.gif&h=100&w=100", filesize("image.php?url=uploads/pic.gif&h=100&w=100")); )4th Now save the fread data in the database5th Delete the image which was used to resize (uploaded image)ENDI know this would take time and i dint give you the script, cause its getting around 12am here and i have school tomorrow and hav to get some sleep. Quote Link to comment Share on other sites More sharing options...
benjam Posted July 31, 2006 Author Share Posted July 31, 2006 Yeah, I am aware of that solution (saving the file and then reading it back), but was hoping there might be a faster, more efficient method. Quote Link to comment Share on other sites More sharing options...
ryanlwh Posted July 31, 2006 Share Posted July 31, 2006 try ob_start() and ob_get_content() Quote Link to comment Share on other sites More sharing options...
benjam Posted July 31, 2006 Author Share Posted July 31, 2006 I tried that, and it worked, but I've decided to go with the save and read back method.Thanks for your help everybody. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.