粗体化返回的URL

时间:2015-01-14 21:48:13

标签: javascript html google-apps-script

我正在为我们的组织制作一个上传门户网站,当人们向我们的编码提交文件时,我希望它生成的网址为 BOLD 。我对HTML和编码有基本的了解,但在尝试加粗生成的URL(+ file.getURL())时,我完全迷失了。任何帮助将不胜感激。以下是我正在使用的所有编码。

form.html

<form id="myForm">
<h1>NHD Paper Upload</h1>
<label>Name</label>
<br />
<input type="text" name="myName" placeholder="Enter your full name..">
<p><label>Division</label>
<br />
<input type="text" name="myDivision" placeholder="(ex. Junior or Senior)"></p>
<p><label>School</label>
<br />
<input type="text" name="mySchool" placeholder="Enter your school.."></p>
<p><label>Affiliate</label>
<br />
<input type="text" name="myAffiliate" placeholder="Enter your affiliate.."></p>
<p><label>Select file to upload. Make sure your file is labeled in the following manner: <b>LastName_Division_School_State.pdf</b></label></p>
<input type="file" name="myFile">
<input type="submit" value="Submit File" 
       onclick="this.value='Please be patient while your paper is uploading..';
                google.script.run.withSuccessHandler(fileUploaded)
                .uploadFiles(this.parentNode);
                return false;">
<p>
<label><b>Once upload is successful please stay on this window to copy and paste the URL produced on the next screen into registration.</b></label>
<br />
<label><b>If you have any issues or questions please send an email to <a href="mailto:elaine@nhd.org">elaine@nhd.org</a>.</b></label>
</p>
</form>

<div id="output"></div>

<script>
    function fileUploaded(status) {
        document.getElementById('myForm').style.display = 'none';
        document.getElementById('output').innerHTML = status;
    }
</script>

<style>
 input { display:block; margin: 20px; }
</style>

server.gs

function doGet(e) {
  return HtmlService.createHtmlOutputFromFile('form.html');
}

function uploadFiles(form) {

  try {

    var dropbox = "NHD Papers";
    var folder, folders = DriveApp.getFoldersByName(dropbox);

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

    var blob = form.myFile;    
    var file = folder.createFile(blob);    
    file.setDescription("Uploaded by " + form.myName + ", Division: " + form.myDivision + ", School: " + form.mySchool + ", State: " + form.myState);

    return "File uploaded successfully! Copy and paste the following URL into registration: " + file.getUrl();

  } catch (error) {

    return error.toString();
  }

}

非常感谢任何帮助。我正在使用Google Script进行此操作。

1 个答案:

答案 0 :(得分:1)

你有没有使用b标签的原因?像这样:

"<b>" + file.getUrl() + "</b>";