2

这有点疯狂,发生在我的 Ubuntu 操作系统上。

尝试使用以下脚本上传文件,它在上传文件夹中创建一个零字节的文件,不知道出了什么问题。有人可以看看吗。

这是我附加的脚本

  1. file1 - 文件输入 html 元素的名称。
  2. uploadbtn - 提交按钮的名称。

代码:

// App Config 

$app_dir = '.';

$uploaddir = $app_dir . '/uploads/';

$filetype  = 'text/xml';
if ( isset($_POST['uploadbtn'] ) ){
        // Upload a file
        print_r( $_FILES );
        if ( !isset($_FILES['file1']['name']) || $_FILES['file1']['name'] == '' ) {
                echo 'No files uploaded, Pls upload a file';
                exit;
        }
        //print_r ( $_FILES ); 

        $filename = basename( $_FILES['file1']['name'] );

        $uploadfile = $uploaddir . $filename ;

        if ($_FILES['file1']['type'] != $filetype ) {
                echo 'Sorry, your file was not of the ' . $filetype . ' mimetype (yours was ' . $_FILES['file1']['type'] . ').';
                exit;
        } // End filetype check 

        $upload = move_uploaded_file($_FILES['file1']['tmp_name'], $uploadfile );

        if ( !$upload ){
                echo ' Uploading UNSUCCESSFUL ';
                print_r( $_FILES );
        } else {
                echo ' Uploading Successfulllllllllllllll';
        }

}
4

0 回答 0