Javascript 精细上载程序Bitnami wampstack上载失败
我尝试在我的网站上实现演示,一切都很好,但当我尝试上载文件时,控制台中出现了以下内容:Javascript 精细上载程序Bitnami wampstack上载失败,javascript,php,windows,file-upload,bitnami,Javascript,Php,Windows,File Upload,Bitnami,我尝试在我的网站上实现演示,一切都很好,但当我尝试上载文件时,控制台中出现了以下内容: responseText={“error”:“服务器错误。上传目录不可写”,“上传名称”:null} 我已经搜索了其他类似的问题,但似乎没有一个对我有效,一些答案谈到了{success:true}但我不明白它们的意思或集合在哪里,我认为这并不重要,因为在演示代码中没有success:true属性 我还尝试使用以下命令设置要上载图像的文件夹权限(即/project root/tmp):cacls apache2
responseText={“error”:“服务器错误。上传目录不可写”,“上传名称”:null}
我已经搜索了其他类似的问题,但似乎没有一个对我有效,一些答案谈到了{success:true}但我不明白它们的意思或集合在哪里,我认为这并不重要,因为在演示代码中没有success:true属性
我还尝试使用以下命令设置要上载图像的文件夹权限(即/project root/tmp):cacls apache2\htdocs\project\tmp/t/e/g everyer:f
,但这不起作用。这个插件非常好,但我认为他们应该在文档中放更多的例子。任何帮助都将不胜感激
这是我的模板:
<div class="qq-uploader-selector qq-uploader" qq-drop-area-text="Drop files here">
<div class="qq-total-progress-bar-container-selector qq-total-progress-bar-container">
<div role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" class="qq-total-progress-bar-selector qq-progress-bar qq-total-progress-bar"></div>
</div>
<div class="qq-upload-drop-area-selector qq-upload-drop-area" qq-hide-dropzone>
<span class="qq-upload-drop-area-text-selector"></span>
</div>
<div class="buttons">
<div class="qq-upload-button-selector qq-upload-button">
<div>Select files</div>
</div>
</div>
<span class="qq-drop-processing-selector qq-drop-processing">
<span>Processing dropped files...</span>
<span class="qq-drop-processing-spinner-selector qq-drop-processing-spinner"></span>
</span>
<ul class="qq-upload-list-selector qq-upload-list" aria-live="polite" aria-relevant="additions removals">
<li>
<div class="qq-progress-bar-container-selector">
<div role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" class="qq-progress-bar-selector qq-progress-bar"></div>
</div>
<span class="qq-upload-spinner-selector qq-upload-spinner"></span>
<img class="qq-thumbnail-selector" qq-max-size="100" qq-server-scale>
<span class="qq-upload-file-selector qq-upload-file"></span>
<span class="qq-edit-filename-icon-selector qq-edit-filename-icon" aria-label="Edit filename"></span>
<input class="qq-edit-filename-selector qq-edit-filename" tabindex="0" type="text">
<span class="qq-upload-size-selector qq-upload-size"></span>
<button type="button" class="qq-btn qq-upload-cancel-selector qq-upload-cancel">Cancel</button>
<button type="button" class="qq-btn qq-upload-retry-selector qq-upload-retry">Retry</button>
<button type="button" class="qq-btn qq-upload-delete-selector qq-upload-delete">Delete</button>
<span role="status" class="qq-upload-status-text-selector qq-upload-status-text"></span>
</li>
</ul>
<dialog class="qq-alert-dialog-selector">
<div class="qq-dialog-message-selector"></div>
<div class="qq-dialog-buttons">
<button type="button" class="qq-cancel-button-selector">Close</button>
</div>
</dialog>
<dialog class="qq-confirm-dialog-selector">
<div class="qq-dialog-message-selector"></div>
<div class="qq-dialog-buttons">
<button type="button" class="qq-cancel-button-selector">No</button>
<button type="button" class="qq-ok-button-selector">Yes</button>
</div>
</dialog>
<dialog class="qq-prompt-dialog-selector">
<div class="qq-dialog-message-selector"></div>
<input type="text">
<div class="qq-dialog-buttons">
<button type="button" class="qq-cancel-button-selector">Cancel</button>
<button type="button" class="qq-ok-button-selector">Ok</button>
</div>
</dialog>
</div>
和my endpoint.php(与以下内容几乎相同):
allowedExtensions=array();//默认情况下允许的所有文件类型
//以字节为单位指定最大文件大小。
$uploader->sizeLimit=null;
//指定javascript中设置的输入名称。
$uploader->inputName=“qqfile”;//默认情况下匹配Fine Uploader的默认inputName值
//如果要使用分块/恢复功能,请指定临时保存零件的文件夹。
$uploader->chunksFolder=“chunks”;
$method=get_request_method();
//这将检索“预期的”请求方法。通常情况下,这是
//请求的实际方法。但是,有时候,预期的请求方法
//必须隐藏在请求的参数中。例如,当试图
//使用POST请求删除文件。在这种情况下,“删除”将与
//请求包含在“\u方法”参数中。
函数get\u request\u method(){
全局$HTTP_原始_后_数据;
if(isset($HTTP_原始_POST_数据)){
parse_str($HTTP_RAW_POST_DATA,$\u POST);
}
如果(isset($\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\{
返回$_POST[“_方法”];
}
返回$服务器[“请求方法”];
}
如果($method==“POST”){
标题(“内容类型:文本/普通”);
//假设您将chunking.success.endpoint设置为指向此处,查询参数为“done”。
//例如:/myserver/handlers/endpoint.php?完成
如果(设置($_GET[“done”])){
$result=$uploader->combineChunks(“文件”);
}
//处理上传请求
否则{
//使用文件夹的名称调用handleUpload(),相对于PHP的getcwd()
$result=$uploader->handleUpload(“tmp”);
//要返回用于上载文件的名称,可以使用以下行。
$result[“uploadName”]=$uploader->getUploadName();
}
echo json_编码($result);
}
//用于删除文件请求
else if($method==“DELETE”){
$result=$uploader->handleDelete(“文件”);
echo json_编码($result);
}
否则{
标题(“不允许使用HTTP/1.0 405方法”);
}
?>
问题在于文件夹的路径:
// Call handleUpload() with the name of the folder, relative to PHP's getcwd()
$result = $uploader->handleUpload("tmp")
注释说这是相对于PHP的getcwd()的,但是当我回显该函数时,它会得到根项目,因此在末尾,文件夹路径是相对于endpoint.PHP文件的位置的。如果您遇到与我相同的问题,请小心文件夹路径
以下是我的working endpoint.php:
<?php
// Include the upload handler class
require_once "handler.php";
$uploader = new UploadHandler();
// Specify the list of valid extensions, ex. array("jpeg", "xml", "bmp")
$uploader->allowedExtensions = array(); // all files types allowed by default
// Specify max file size in bytes.
$uploader->sizeLimit = null;
// Specify the input name set in the javascript.
$uploader->inputName = "qqfile"; // matches Fine Uploader's default inputName value by default
// If you want to use the chunking/resume feature, specify the folder to temporarily save parts.
$uploader->chunksFolder = "../../uploads";
$method = get_request_method();
// This will retrieve the "intended" request method. Normally, this is the
// actual method of the request. Sometimes, though, the intended request method
// must be hidden in the parameters of the request. For example, when attempting to
// delete a file using a POST request. In that case, "DELETE" will be sent along with
// the request in a "_method" parameter.
function get_request_method() {
global $HTTP_RAW_POST_DATA;
if(isset($HTTP_RAW_POST_DATA)) {
parse_str($HTTP_RAW_POST_DATA, $_POST);
}
if (isset($_POST["_method"]) && $_POST["_method"] != null) {
return $_POST["_method"];
}
return $_SERVER["REQUEST_METHOD"];
}
if ($method == "POST") {
header("Content-Type: text/plain");
// Assumes you have a chunking.success.endpoint set to point here with a query parameter of "done".
// For example: /myserver/handlers/endpoint.php?done
if (isset($_GET["done"])) {
$result = $uploader->combineChunks("../../uploads");
}
// Handles upload requests
else {
// Call handleUpload() with the name of the folder, relative to PHP's getcwd()
$result = $uploader->handleUpload("../../uploads"); //this folder was created in the root project, at the same level as wp-content
// To return a name used for uploaded file you can use the following line.
$result["uploadName"] = $uploader->getUploadName();
}
echo json_encode($result);
}
// for delete file requests
else if ($method == "DELETE") {
$result = $uploader->handleDelete("../../uploads");
echo json_encode($result);
}
else {
header("HTTP/1.0 405 Method Not Allowed");
}
?>
allowedExtensions=array();//默认情况下允许的所有文件类型
//以字节为单位指定最大文件大小。
$uploader->sizeLimit=null;
//指定javascript中设置的输入名称。
$uploader->inputName=“qqfile”;//默认情况下匹配Fine Uploader的默认inputName值
//如果要使用分块/恢复功能,请指定临时保存零件的文件夹。
$uploader->chunksFolder=“../../uploads”;
$method=get_request_method();
//这将检索“预期的”请求方法。通常情况下,这是
//请求的实际方法。但是,有时候,预期的请求方法
//必须隐藏在请求的参数中。例如,当试图
//使用POST请求删除文件。在这种情况下,“删除”将与
//请求包含在“\u方法”参数中。
函数get\u request\u method(){
全局$HTTP_原始_后_数据;
if(isset($HTTP_原始_POST_数据)){
parse_str($HTTP_RAW_POST_DATA,$\u POST);
}
如果(isset($\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\{
返回$_POST[“_方法”];
}
返回$服务器[“请求方法”];
}
如果($method==“POST”){
标题(“内容类型:文本/普通”);
//假设您将chunking.success.endpoint设置为指向此处,查询参数为“done”。
//例如:/myserver/handlers/endpoint.php?完成
如果(设置($_GET[“done”])){
$result=$uploader->combineChunks(“../../uploades”);
}
//处理上传请求
否则{
//使用文件夹的名称调用handleUpload(),相对于PHP的getcwd()
$result=$uploader->handleUpload(“../../uploads”);//此文件夹是在根项目中创建的,与wp内容处于同一级别
//要返回用于上载文件的名称,可以使用以下行。
$result[“uploadName”]=$uploader->getUploadName();
}
echo json_编码($result);
}
//用于删除文件请求
else if($method==“DELETE”){
$result=$uploader->handleDelete(“../../uploades”);
echo json_编码($result);
}
否则{
标题(“不允许使用HTTP/1.0 405方法”);
}
?>
// Call handleUpload() with the name of the folder, relative to PHP's getcwd()
$result = $uploader->handleUpload("tmp")
<?php
// Include the upload handler class
require_once "handler.php";
$uploader = new UploadHandler();
// Specify the list of valid extensions, ex. array("jpeg", "xml", "bmp")
$uploader->allowedExtensions = array(); // all files types allowed by default
// Specify max file size in bytes.
$uploader->sizeLimit = null;
// Specify the input name set in the javascript.
$uploader->inputName = "qqfile"; // matches Fine Uploader's default inputName value by default
// If you want to use the chunking/resume feature, specify the folder to temporarily save parts.
$uploader->chunksFolder = "../../uploads";
$method = get_request_method();
// This will retrieve the "intended" request method. Normally, this is the
// actual method of the request. Sometimes, though, the intended request method
// must be hidden in the parameters of the request. For example, when attempting to
// delete a file using a POST request. In that case, "DELETE" will be sent along with
// the request in a "_method" parameter.
function get_request_method() {
global $HTTP_RAW_POST_DATA;
if(isset($HTTP_RAW_POST_DATA)) {
parse_str($HTTP_RAW_POST_DATA, $_POST);
}
if (isset($_POST["_method"]) && $_POST["_method"] != null) {
return $_POST["_method"];
}
return $_SERVER["REQUEST_METHOD"];
}
if ($method == "POST") {
header("Content-Type: text/plain");
// Assumes you have a chunking.success.endpoint set to point here with a query parameter of "done".
// For example: /myserver/handlers/endpoint.php?done
if (isset($_GET["done"])) {
$result = $uploader->combineChunks("../../uploads");
}
// Handles upload requests
else {
// Call handleUpload() with the name of the folder, relative to PHP's getcwd()
$result = $uploader->handleUpload("../../uploads"); //this folder was created in the root project, at the same level as wp-content
// To return a name used for uploaded file you can use the following line.
$result["uploadName"] = $uploader->getUploadName();
}
echo json_encode($result);
}
// for delete file requests
else if ($method == "DELETE") {
$result = $uploader->handleDelete("../../uploads");
echo json_encode($result);
}
else {
header("HTTP/1.0 405 Method Not Allowed");
}
?>