-3

I am developing a site as a student project, in which you're supposed to login > take a picture with your camera > display all the pictures ever taken > like and comments picture.

I already have that piece of Javascript which draw an image on a canvas from the camera stream. Then it sets a new element and set its 'src' attr to canvas.toDataURL(img/png); to display a preview for the pic just taken.

Now what I want, and can't find a solution for, is saving this new created picture to my server on a /img/photo1.png directory OR stock a link on the database that I can output later.

Thanks for helping.

(BTW, I'm not allowed to use any library (no JQuery please !!))

  • You'll have to POST a form to your server, or do it with XMLHttpRequest. – Pointy Feb 06 '17 at 15:57
  • Google "php file upload" –  Feb 06 '17 at 16:00
  • add the ```canvas.toDataURL(img/png);``` to an input text box in a form, and submit that form. then write a PHP code to for upload photo like usual. – Afif Zafri Feb 06 '17 at 16:05
  • See http://stackoverflow.com/questions/37491759/trying-to-pass-todataurl-with-over-524288-bytes-using-input-type-text/ – guest271314 Feb 06 '17 at 16:07
  • thanks for all you answers, I still have issues tho... the problem is, the picture I'm trying to upload is not a file uploaded by the user but a javascript object... – Foulques de Moncade Feb 07 '17 at 18:23
  • Ok I found my answer, the thing I didn't understand is that you can (almost) directly use file_put_contents (php) on the string canvas.toDataURL(img/png) returns ! – Foulques de Moncade Feb 10 '17 at 14:47

1 Answers1

0

Ok I found my answer, the thing I didn't understand is that you can (almost) directly use file_put_contents (php) on the string canvas.toDataURL(img/png) returns !