我使用的是Blueimp jQuery文件上传工具。如何动态更改上传文件夹?
我试过这样做:
UploadHandler.php
$dirPath = $_POST['dirpath'];
'upload_dir' => '../../mydir/'.$dirPath,
'upload_url' => '../../mydir/'.$dirPath,带表单的HTML:
<input type="text" name="dirpath" value="123"/>发布于 2015-08-16 00:02:26
尝试创建一个包含"dirpath“属性的对象,File对象,在change事件中,利用$.post()将包含"dirpath”的对象,File对象发送到php文件
$("form").on("change", function(e) {
e.preventDefault();
var res = {
"dirpath": $("input[type=text]", this).val(),
"file": e.target.files
};
// $.post(url, res);
console.log(res)
});<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">
</script>
<form>
<input type="text" name="dirpath" value="123" />
<input type="file" />
</form>
发布于 2015-08-16 02:05:59
我做到了。也许真的有人派上用场了
HTML
<textarea type="text" name="dirpath">123</textarea>UploadHandler.php
'upload_dir' => '../../'.$dirPath = $_POST['dirpath'].'/',
'upload_url' => '../../'.$dirPath = $_POST['dirpath'].'/',如果你需要重命名上传的文件,你也可以使用这个:
protected function trim_file_name($file_path, $name, $size, $type, $error, $index, $content_range) {
$name = $_POST['dirpath'];
return $name;
}https://stackoverflow.com/questions/32026121
复制相似问题