2016-06-27 4 views
0

3 개의 파일과 확인란, 라디오 버튼 및 텍스트 영역과 같은 기타 입력 유형을 업로드 할 수있는 HTML 데이터 양식을 만들고 있습니다. 이제 업로드 파일을 Google 드라이브로 보내는 방법을 알고 싶습니다. 그들은 Google 스크립트를 사용하여 새로 만든 폴더에 저장할 수 있습니다. 누구든지 나를 도울 수 있습니까?HTML 형식으로 파일을 두 개 이상 업로드하는 방법은 무엇입니까?

<!DOCTYPE html> 
<html> 
    <head> 
    <script> 



    </script> 
    </head> 

<body background="data_image1.jpg"> 
    <link rel ="stylesheet" href ="styles.css"> 
    <form id="myForm"> 

    <font size="6" color="blue">IS-GEO DATA COLLECTION </font> 
    <font size="3" color="red" >This form can be used to capture data and metadata collected during field-trips.</font> 
    <h4> Type of Data:</h4> 

    <br><h4> <font color="red">Please select the type of data that you are collecting: </font></h4> 

    <input type= "radio" name= "Typedata" id="imageRadioButton" >Image <br> 

    <br><input type= "radio" name="Typedata" id="temperatureRadioButton">Temperature Reading<br> 

    <br><input type= "radio" name= "Typedata" id="waterLevelRadioButton" >Water-Level Reading<br> 

    <br><input type= "radio" name="Typedata" id="fieldObservationRadioButton"> Field Observation<br> 

    <br><input type= "radio" name="Typedata" id="otherRadioButton"> Other<br> 

    <br><input type= "text" name="Typedata" id="otherRadioButton"><br>      

    <br> Date of Collection: <br > 
    <br> <input type="date" name="date" id="dateText"> <br> 

    <br> Time of Collection: <br> 
    <br> <input type="time" name="time" id="timeText"> <br> 

    <br> Location: <br> 

    <br> <input type= "text" name="location" id="locationText"> <br> 

    <br> GPS Coordinates (latitude, longitude decimal degrees) Example: 19.3221, -100.1234:<br> 
    <br> <input type= "text" name="coordinates" id="coorinatesText"> <br> 

    <br><h4> <font color="red">Select Applicable Categories of Data or the Features Represented by Data: </font> </h4> 

    <br> <input type="checkbox" name="categories" id="buildingCheckBox"> Building<br> 

    <br> <input type="checkbox" name="categories" id ="vegetationCheckBox">Vegetation<br> 

    <br> <input type= "checkbox" name="categories" id="waterBodycheckBox"> Water Body<br> 

    <br> <input type= "checkbox" name="categories" id="soilCheckBox" > Soil<br> 

    <br> <input type= "checkbox" name="categories" id="concreteCheckBox"> Concrete<br> 

    <br> <input type= "checkbox" name="categories" id="vehicleCheckBox">Vehicle<br> 

    <br> <input type= "checkbox" name="categories" id="moutainCheckBox"> Mountain <br> 

    <br> <input type= "checkbox" name="categories" id="landsubsidence"> Land Subsidence <br> 

    <br> <input type= "checkbox" name="categories" id="fossilCheckBox">Fossil <br> 

    <br> <input type= "checkbox" name="categories" id="signageCheckBox" >Signage<br> 

    <br> <input type="checkbox" name="categories" id="bridgesCheckBox"> Bridges <br> 

    <br> <input type= "checkbox" name="categories" id="tunnelsCheckBox"> Tunnels <br> 

    <br> <input type= "checkbox" name="categories" id="roadCheckBox"> Road<br> 

    <br> <input type= "checkbox" name="categories" id="trafficCheckBox"> Traffic Light <br> 

    <br> <input type= "checkbox" name="categories" id="parkCheckBox">Park <br> 

    <br> <input type= "checkbox" name="categories" id="diggingsiteCheckBox">Digging Site <br> 

    <br> <input type="checkbox" name="categories" id="otherCheckBox">Other<br> 
    <input type="text" name="categories" id="otherCheckBox" > <br> 

    <br> URL to the Photo of the Object (Web Accessible Path to the Location of the Photo) <br> 
    <br> <input type="text" name="File" id="filephoto"> 
    <input type="file" name="File" id="filephoto"> <br> 

    <br> URL to the Photo of Hand-Written Field Notes: <br> 
    <br> <input type="text" name="file1" id="filenotes"> 
    <input type="file" name="myFile1" id="filenotes"> <br> 

    <br>Data Description (Use Keywords or Sentences): <br> 
    <br> <input type="text" name="description" id="Description"> <br> 
    <input type="file" name="File2" id="description"> 
    <br>URL to Related Data:<br> 
    <br> <input type="text" name="file3" id="filerelated"> 
    <label for="myFile">Upload Attachment(s):</label> 
     <br> <input type="file" name="filename" id="myFile" multiple> 

     <!--<button type='submit'>Submit</button 
    onclick="" method="post"> --> 

    <!-- <div id='success'></div> 
     <button type='submit'>Send</button> --> 


    <!--<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> 
    Custom Theme JavaScript 
    <script src='google-sheet.js'></script>--> 


      <input type="button" value="Submit" onclick="iteratorFileUpload()"> 

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> 
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script> 



</form> 
</body> 
</html> 

이것은 내 Google 스크립트 파일입니다.

function doGet() { 
    return HtmlService.createHtmlOutputFromFile('form') 
    .setSandboxMode(HtmlService.SandboxMode.IFRAME); 
} 

function uploadFileToDrive(base64Data, fileName) { 
    try{ 
    var splitBase = base64Data.split(','), 
     type = splitBase[0].split(';')[0].replace('data:',''); 

    var byteCharacters = Utilities.base64Decode(splitBase[1]); 
    var ss = Utilities.newBlob(byteCharacters, type); 
    ss.setName(fileName); 

    var dropbox = "studentfile2"; // Folder Name 
    var folder, folders = DriveApp.getFoldersByName(dropbox); 

    if (folders.hasNext()) { 
     folder = folders.next(); 
    } else { 
     folder = DriveApp.createFolder(dropbox); 
    } 
    var file = folder.createFile(ss); 

    return file.getName(); 
    }catch(e){ 
    return 'Error: ' + e.toString(); 
    } 
} 
+0

A [mcve] 만드는 방법에 대해 읽어보십시오를 형성하기 위해 추가해야합니다. 기본적으로 문제를 식별하는 데 필요한 코드 만 줄이십시오. 또한,'font' 엘리먼트는 looooong 시간 동안 더 이상 사용되지 않습니다;). –

답변

1
<input type="file" name="file_array[]" /> 

$_FILES['file_array'] 

는에 enctype = "multipart/form-data"로

관련 문제