【发布时间】:2017-02-02 13:44:26
【问题描述】:
我尝试使用自己的目录将文件上传到其中,但在加载页面“upload_test.php”时出现错误
userPath is not defined
这两天我尝试了很多解决方案,但都没有奏效:(
这是我的页面代码
<form id="fileupload" action="UploadHandler.php?userPath=<?php echo $MYDIR;?>" method="POST" enctype="multipart/form-data">
这是我在 main.js 中的代码
$('#fileupload').fileupload({
// Uncomment the following to send cross-domain cookies:
//xhrFields: {withCredentials: true},
url: 'file_upload/server/php/index.php?userPath='+userPath,
});
对于 index.php
error_reporting(E_ALL | E_STRICT);
require('UploadHandler.php');
class CustomUploadHandler extends UploadHandler {
protected function get_user_id() {
return $_REQUEST['userPath'];
}
protected function set_additional_file_properties($file) {
$file->deleteUrl = $this->options['script_url']
.$this->get_query_separator($this->options['script_url'])
.$this->get_singular_param_name()
.'='.rawurlencode($file->name)
.'&userPath='.$_REQUEST['userPath']
;
$file->deleteType = $this->options['delete_type'];
if ($file->deleteType !== 'DELETE') {
$file->deleteUrl .= '&_method=DELETE';
}
if ($this->options['access_control_allow_credentials']) {
$file->deleteWithCredentials = true;
}
}
}
$upload_handler = new CustomUploadHandler(array(
'user_dirs' => true,
));
【问题讨论】:
标签: jquery upload customization