I want my code to select image , resize it and then upload it to a google drive folder.. I have no problem with the selecting and uploading file as it works fine but I cannot have the resizing code work in between.
I have the following code to upload images to a folder in google drive using Google script..
GS:
function uploadFiles(form) {
try {
var dropbox = "STpics";
var folder, folders = DriveApp.getFoldersByName(dropbox);
var data = getData();
var myName2 = form.sorp3;
if (folders.hasNext()) {
folder = folders.next();
} else {
folder = DriveApp.createFolder(dropbox);
}
var blob = form.myFile;
var file = folder.createFile(blob);
file.setName(Mohd +".jpg");
file.setDescription("Uploaded by " + xxxxx);
} catch (error) {
return error.toString();
}
}
Html:
<form id="myForm">
<input type="file" name="myFile" accept=".jpg,.jpeg,.png,.gif" /> <br><br>
<input type="submit" value="upload"
onclick="this.value='uploading..';
google.script.run.withSuccessHandler(fileUploaded)
.uploadFiles(this.parentNode);
return false;">
</form>
<div id="output"></div>
<script>
function fileUploaded(status) {
document.getElementById('myForm').style.display = 'none';
document.getElementById('output').innerHTML = status;
}
</script>
<div id="Message12"></div>
<div id="Message"></div>
<script>
function DataSaved(){
document.getElementById('Message').innerHTML = "sending...";
<?var url = getScriptUrl();?>
window.open(
'<?=url?>?page=2 ',
'_top' // <- This is what makes it open in a new window.
);
};
</script>
I got many scrips of HTML5 canvas to resize images but I could not integrate it with the above working code! Any help is apprecited.