0

I'm trying to run javascript code to ensure that the div content is uploaded as PNG to the user's Google Drive.

I've already managed to start uploading to Drive via input [type = "file"] - so I know the upload is working properly. Now, however, I would need to ensure that the user does not select a file from his local storage, but that the contents of the div element are stored on his Drive.

I tried it with the following code, but it gives me the following error in the console: Uncaught TypeError: canvas.toBlob is not a function.

var canvas = document.getElementById('preview'); canvas.toBlob(function(blob) { var file = document.createElement('img'), url = URL.createObjectURL(blob); var upload = new Upload(file); upload.doUpload(); URL.revokeObjectURL(url); 

I believe that there is a better option than to deal with it through blob, but so far I have not been able to come up with anything like that.

7
  • I have to apologize for my poor English skill. Unfortunately, I cannot understand Now, however, I would need to ensure that the user does not select a file from his local storage, but that the contents of the div element are stored on his Drive.. Can I ask you about the detail of your current issue? Commented Jan 7, 2022 at 3:08
  • Okay, I'll try to simplify it.After clicking the "Save to Google Drive" button, the content of a particular div will be saved as a PNG to the user's Google Drive. What I've accomplished is that I can upload a user's file on his computer to his Google Drive. But I still can't figure out how to save div content in PNG format to his Google Drive. Commented Jan 7, 2022 at 11:32
  • @Tanaike Did I explain it correctly? Commented Jan 10, 2022 at 21:45
  • Thank you for replying. I have to apologize for my poor English skill, again. Unfortunately, I cannot still understand your question. But I would like to try to understand it. When I could correctly understand it, I would like to think of the solution. I would be grateful if you can forgive my poor English skill. Commented Jan 11, 2022 at 0:23
  • @Tanike Ok, so I will try to simplify it once more. Click "Save to Google Drive" button -> HTML div saved to user's Google Drive as a PNG file. doUpload() function is working, my problem is: DIV -> File object. I have used code from: codingshiksha.com/… , but it is working just with file from INPUT. Commented Jan 11, 2022 at 14:23

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.