我正在实施良好的上传器。这是我所做的:
1) 我添加了以下 html 和 js 类:
<link rel="stylesheet" href="Content/fineuploader-3.4.1.css" />
<script type="text/javascript" src="Scripts/jquery.fineuploader-3.4.1.min.js"></script>
HTML
<input type="text" class="input-medium" placeholder="Document Type" data-bind="value: type"/>
<div id="fine-uploader-basic" class="btn btn-success" data-bind="click:$root.uploadFile">
<i class="icon-upload icon-white"></i> Click to upload
</div>
<div id="messages"></div>
JS文件
uploadFile: function(data) {
var uploader = new qq.FineUploader({
element: $('#fine-uploader')[0],
debug: true,
request: {
endpoint: "php/fileupload.php"
}
});
}
精细上传.php 文件:
<?php
$file = $_FILES['qqfile'];
$uploadDirectory = 'uploads';
$target = $uploadDirectory.DIRECTORY_SEPARATOR.$file['files.php'];
$result = null;
if (move_uploaded_file($file['tmp_name'], $target)){
$result = array('success'=> true);
$result['uploadName'] = $file['name'];
} else {
$result = array('error'=> 'Upload failed');
}
header("Content-Type: text/plain");
echo json_encode($result);
?>
files.php(存储文件的位置)
<?php
// Include the uploader class
require_once 'php/fileupload.php';
$uploader = new qqFileUploader();
// Specify the list of valid extensions, ex. array("jpeg", "xml", "bmp")
$uploader->allowedExtensions = array();
// Specify max file size in bytes.
$uploader->sizeLimit = 10 * 1024 * 1024;
// Specify the input name set in the javascript.
$uploader->inputName = 'qqfile';
// If you want to use resume feature for uploader, specify the folder to save parts.
$uploader->chunksFolder = 'chunks';
// Call handleUpload() with the name of the folder, relative to PHP's getcwd()
$result = $uploader->handleUpload('uploads');
// To save the upload with a specified name, set the second parameter.
// $result = $uploader->handleUpload('uploads/', md5(mt_rand()).'_'.$uploader->getName());
// To return a name used for uploaded file you can use the following line.
$result['uploadName'] = $uploader->getUploadName();
header("Content-Type: text/plain");
echo json_encode($result);
?>
问题:
当我单击该按钮时,它会更改为以下内容:
绿色按钮内的那个红色按钮应该与绿色按钮分开。
而且,选择文件的弹出窗口也不会出现。两个 PHP 文件都有 777 权限。