小编Kil*_*isi的帖子

将Excel文件上传到服务器

我无法将msoffice文件上传到服务器上的文件夹,我可以上传.pdf和图片文件,但不能上传.docx,.xlsx甚至是.txt,据我所知,所有语法看起来都是正确的。这是表格

<form id="Upload" action="upload_file.php" method="post" enctype="multipart/form-data">
    <label for="fileSelect">Navigate and choose:</label>
    <input type="file" name="file" id="fileSelect"><br><br>
    <input class="button" type="submit" name="action" value="Upload to Shared Folder">
</form>
Run Code Online (Sandbox Code Playgroud)

这是upload_file.php

    if(isset($_FILES["file"]["error"])){
if($_FILES["file"]["error"] > 0){
    echo "Error: " . $_FILES["file"]["error"] . "<br>";
} else{
    $allowed = array("jpg" => "image/jpg", "jpeg" => "image/jpeg", "gif" => "image/gif", "png" => "image/png", "doc" => "application/msword", "docx" => "application/msword", "xls" => "application/vnd.ms-excel", "xlsx" => "application/vnd.ms-excel", "pdf" => "application/pdf", "txt" => "application/txt");
    $filename = $_FILES["file"]["name"];
    $filetype = $_FILES["file"]["type"];
    $filesize = $_FILES["file"]["size"];

    // siati …
Run Code Online (Sandbox Code Playgroud)

php excel upload ms-office

3
推荐指数
1
解决办法
5584
查看次数

只允许字母和空格,并且每个单词都大写

我只需要允许输入字母,我还需要使用 javascript 将每个单词的第一个字母大写。我有第一个在按键上工作,我想要第二个在 onblur 上工作,但我无法让它工作。如果我单独使用它,它可以正常工作。我尝试了很多东西,但我一定错过了一些小东西,我就是不知道它是什么。

HTML

<tr>
<td>
<input type="text" name="first_names" onkeypress="return isAlfa(event)" onblur="toTitleCase()">
</td>
<td>
<input type="text" name="last_names" onkeypress="return isAlfa(event)" onblur="toTitleCase()">
</td>
</tr>
Run Code Online (Sandbox Code Playgroud)

爪哇脚本

function isAlfa(evt) {
    evt = (evt) ? evt : window.event;
    var charCode = (evt.which) ? evt.which : evt.keyCode;
    if (charCode > 32 && (charCode < 65 || charCode > 90) && (charCode < 97 || charCode > 122)) {
        return false;
    }
    return true;
}

function toTitleCase(str)
{
    return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
} …
Run Code Online (Sandbox Code Playgroud)

html javascript forms input

1
推荐指数
1
解决办法
1090
查看次数

标签 统计

excel ×1

forms ×1

html ×1

input ×1

javascript ×1

ms-office ×1

php ×1

upload ×1