After resizing the image using Javascript, how to upload via PHP using $ _POST

I am mainly trying to encode a webpage where users can upload images via iPhone / Andoid and Desktop. These pictures should be saved as a thumbnail in. / userupload, and the link to it is stored in the MySQL database.

I realized this with a simple HTML form loading and PHP Script cut out the part, which should be a thumbnail, saving a new image and writing a link to the database. It sounds simple, but it’s difficult that the iPhone pictures are really big now, and mobile uploading a 6 MB image will take a lot of cia 3G time. So I was looking for an opportunity to make resizing on the client using Javascript. Through stackoverflow, I found this a very useful little script that I am using to resize now.

Unfortunately, my Javascript and HTML5 skills are not very developed, and I don’t know how to transfer the modified image, which is now displayed via the <img> along with another <form> input, to my backend PHP script to save the image and write the link to the database. Do you have any ideas?

Thanks in advance

+4
source share
1 answer

Well, since you have a base64 encoded image in the src attribute of your resized <img> , you can put this value in hidden input and load the bas64 string (instead of the real image). Then you can decode the image in your PHP script and save it as you need.

0
source

All Articles