homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

Send canvas as image upload, not base64 text

5+ Year Member

Msg#: 4518078 posted 6:02 pm on Nov 11, 2012 (gmt 0)

I have an html form that allows users to to upload images to my website. To save bandwidth, time and other resources I'm starting to use a script that implements canvas resizing, if supported, before uploading the image. The base of the script you can find by searching for "Resizing images before upload using HTML5 canvas".

I'm running into a problem and wondering if there are no ways around it. If js is disabled or canvas is not supported in the browser than the images are uploaded. Else, if this script runs than instead of images, base64 text of the image is returned. This complicates the backend script that receives the images (or now base64 text). Is there a way of sending the resized images themselves and not the text?



Msg#: 4518078 posted 3:15 am on Nov 16, 2012 (gmt 0)

Thank you.


WebmasterWorld Senior Member 10+ Year Member

Msg#: 4518078 posted 6:40 am on Nov 16, 2012 (gmt 0)

There are base64 decode JavaScript examples out there. The PHP.js project has a nice piece of code, for example. I would be a little concerned about potential memory issues when you have a canvas image and a binary copy being processed simultaneously by JavaScript, so it might actually be best to let your server-based script handle the decoding.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved