0% found this document useful (0 votes)
11 views

Upload File

The document provides instructions to update code and scripts to add two columns to a Google Sheet to store file links, create two folders in Google Drive, and update the code to handle uploading files to the folders and retrieving the file URLs.

Uploaded by

app.athome.01
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Upload File

The document provides instructions to update code and scripts to add two columns to a Google Sheet to store file links, create two folders in Google Drive, and update the code to handle uploading files to the folders and retrieving the file URLs.

Uploaded by

app.athome.01
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

Tambahkan 2 Kolom di googlesheet untuk menampung link file

Buat 2 Folder di Google Drive

Update Code.gs
///////////////////////////////////////////////////////////////////////////////////
/

var folder1 = DriveApp.getFolderById('fd');//ganti fd dengan id folder


var folder2 = DriveApp.getFolderById('fd');//ganti fd dengan id folder

-------FILE DIBAWAH ADA UPDATE/PERBAIKAN-------------------------------------------

if (formObject.myFile1 && formObject.myFile2.length > 0) {


var blob1 = formObject.myFile1;
var blob2 = formObject.myFile2;
var file1 = folder1.createFile(blob1);
var file2 = folder2.createFile(blob2);
file1 = file1.getUrl();
file2 = file2.getUrl();
}

-------FILE UPDATE/PENGGANTI UNTUK SCRIPT


DIATAS------------------------------------
-------GANTI SCRIPT BARIS (17-23 DENGAN BARIS 29-
46)--------------------------------

if ((formObject.myFile1.length > 0) && (formObject.myFile2.length > 0)) {


var blob1 = formObject.myFile1;
var blob2 = formObject.myFile2;
var file1 = folder1.createFile(blob1);
var file2 = folder2.createFile(blob2);
file1 = file1.getUrl();
file2 = file2.getUrl();

} else if ((formObject.myFile1.length > 0) && (formObject.myFile2.length == 0))


{
var blob1 = formObject.myFile1;
var file1 = folder1.createFile(blob1);
file1 = file1.getUrl();

} else if ((formObject.myFile2.length > 0) && (formObject.myFile1.length == 0))


{
var blob2 = formObject.myFile2;
var file2 = folder2.createFile(blob2);
file2 = file2.getUrl();
}

-----------------------------------------------------------------------------------
----

file1,
file2,
-----------------------------------------------------------------------------------
----

Update JavaScript
///////////////////////////////////////////////////////////////////////////////////
///

"<th scope='col'>File 1</th>" +


"<th scope='col'>File 2</th>" +

-----------------------------------------------------------------------------------
----

{
targets: [7], //colom 7 adalah kolom file1
className: 'dt-body-center',
"render": function(data, type, row, meta) {
if (type === 'display' && data.length >
20) {
data = '<a href="' + data + '?
text=' + row[7] + '" target="_blank">' + '<i class="fa fa-file" style="font-
size:15px;color:black"></i>' + '</a>';
}
return data;
}
},
{
targets: [8], //colom 8 adalah kolom file2
className: 'dt-body-center',
"render": function(data, type, row, meta) {
if (type === 'display' && data.length >
20) {
data = '<a href="' + data + '?
text=' + row[8] + '" target="_blank">' + '<i class="fa fa-file" style="font-
size:15px;color:black"></i>' + '</a>';
}
return data;
}
},

-----------------------------------------------------------------------------------
----

Update form
///////////////////////////////////////////////////////////////////////////////////
///

<!-- Input type text -->


<div class="form-group">
<label for="file1">File 1</label>
<input type="file" class="form-control"
name="myFile1" id="myFile2">
</div>

<!-- Input type text -->


<div class="form-group">
<label for="file1">File 2</label>
<input type="file" class="form-control"
name="myFile1" id="myFile2">
</div>

-----------------------------------------------------------------------------------
----

You might also like