![](/img/trans.png)
[英]Dropzone.js always auto uploads files. Can't set options on dropzone #id - Laravel - Voyager - Dropzone.js
[英]Uploads through Dropzone.js return '403 forbidden' while other uploads don't
我正在將TinyMCE與包含DropZone.js的文件管理器響應文件管理器一起使用。 通過它上傳文件的所有嘗試均失敗,並返回403 Forbidden錯誤消息。
我試圖將url參數更改為例如"index.php"
和"/ui/scripts/libs/filemanager/upload_notexists.php"
。 如果我在地址欄中輸入“ index.php”和原始網址值,則不會出現錯誤消息。 “ notexists” URL返回404錯誤,因為它不存在。 無論網址如何,上傳總是返回403禁止。
我嘗試設置forceFallback: true
和method: "post"
/ method: "put"
。 它仍然返回403 Forbidden。
這是初始化DropZone.js的代碼:
var allowed_ext = new Array('jpg','jpeg','png','gif','bmp','tiff','svg','doc','docx','rtf','pdf','xls','xlsx','txt','csv','html','xhtml','psd','sql','log','fla','xml','ade','adp','mdb','accdb','ppt','pptx','odt','ots','ott','odb','odg','otp','otg','odf','ods','odp','css','ai','zip','rar','gz','tar','iso','dmg','mov','mpeg','mp4','avi','mpg','wma','flv','webm','mp3','m4a','ac3','aiff','mid','ogg','wav');
//dropzone config
Dropzone.options.myAwesomeDropzone = {
dictInvalidFileType: "Filtypen är ej tillåten.",
dictFileTooBig: "Den uppladdade filen överskrider max storleken.",
dictResponseError: "SERVER ERROR",
paramName: "file", // The name that will be used to transfer the file
maxFilesize: 100, // MB
url: "http://subdomain.example.com/ui/scripts/libs/filemanager/upload.php",
//url: "http://subdomain.example.com/index.php",
accept: function(file, done) {
var extension=file.name.split('.').pop();
extension=extension.toLowerCase();
if ($.inArray(extension, allowed_ext) > -1) {
done();
}
else {
done("Filtypen är ej tillåten.");
}
},
//forceFallback: true,
//method: "post"
};
我嘗試使用小於1 kb的小圖像以及多個較大的圖像。
我還測試了使用以下基本代碼進行上傳的工作原理:
<form method="post" enctype="multipart/form-data">
Fil: <input type="file" name="filer[]" multiple>
<br>
<input type="submit">
</form>
這是phpinfo()的核心部分:
CorePHP Version 5.3.28
Directive Local Value Master Value
allow_call_time_pass_reference On On
allow_url_fopen On On
allow_url_include Off Off
always_populate_raw_post_data Off Off
arg_separator.input & &
arg_separator.output & &
asp_tags Off Off
auto_append_file no value no value
auto_globals_jit On On
auto_prepend_file no value no value
browscap no value no value
default_charset no value no value
default_mimetype text/html text/html
define_syslog_variables Off Off
disable_classes no value no value
disable_functions link,symlink,exec,shell_exec,system,passthru link,symlink,exec,shell_exec,system,passthru
display_errors Off Off
display_startup_errors Off Off
doc_root no value no value
docref_ext no value no value
docref_root no value no value
enable_dl Off Off
error_append_string no value no value
error_log /dev/null /dev/null
error_prepend_string no value no value
error_reporting 30711 30711
exit_on_timeout Off Off
expose_php Off Off
extension_dir /usr/local/php53/lib/php/extensions/no-debug-non-zts-20090626 /usr/local/php53/lib/php/extensions/no-debug-non-zts-20090626
file_uploads On On
highlight.bg #FFFFFF #FFFFFF
highlight.comment #FF8000 #FF8000
highlight.default #0000BB #0000BB
highlight.html #000000 #000000
highlight.keyword #007700 #007700
highlight.string #DD0000 #DD0000
html_errors On On
ignore_repeated_errors Off Off
ignore_repeated_source Off Off
ignore_user_abort Off Off
implicit_flush Off Off
include_path .:/usr/local/lib/php .:/usr/local/lib/php
log_errors Off Off
log_errors_max_len 1024 1024
magic_quotes_gpc Off Off
magic_quotes_runtime Off Off
magic_quotes_sybase Off Off
mail.add_x_header Off Off
mail.force_extra_parameters no value no value
mail.log no value no value
max_execution_time 500 500
max_file_uploads 2000 2000
max_input_nesting_level 64 64
max_input_time -1 -1
max_input_vars 8000 8000
memory_limit 512M 512M
open_basedir no value no value
output_buffering 1 1
output_handler no value no value
post_max_size 1600M 1600M
precision 12 12
realpath_cache_size 16K 16K
realpath_cache_ttl 120 120
register_argc_argv On On
register_globals Off Off
register_long_arrays On On
report_memleaks On On
report_zend_debug On On
request_order no value no value
safe_mode Off Off
safe_mode_exec_dir no value no value
safe_mode_gid Off Off
safe_mode_include_dir no value no value
sendmail_from no value no value
sendmail_path /usr/sbin/sendmail -t -i /usr/sbin/sendmail -t -i
serialize_precision 100 100
short_open_tag On On
SMTP localhost localhost
smtp_port 25 25
sql.safe_mode Off Off
track_errors Off Off
unserialize_callback_func no value no value
upload_max_filesize 800M 800M
upload_tmp_dir no value no value
user_dir no value no value
user_ini.cache_ttl 300 300
user_ini.filename .user.ini .user.ini
variables_order EGPCS EGPCS
xmlrpc_error_number 0 0
xmlrpc_errors Off Off
y2k_compliance On On
zend.enable_gc On On
編輯:我已經設法在共享主機上打開錯誤日志記錄。 它什么也沒顯示。 :c(2014-07-15 18:48)
假設您的文件未上載並且您的URL正確,則似乎該問題與“響應文件管理器”文件的權限有關(403:禁止)。
檢查此文件的所有者和父目錄中的.htaccess。
似乎我的共享主機為每個包含"/../"
POST
數據字符串拋出403 Forbidden
。 作為安全功能...
當響應文件管理器將上載數據發送到upload.php時,它還會發送一個配置變量,在我的情況下是"../../files"
,因此服務器向我"../../files"
了403。
這樣的答案讓我相信這可能是由mod_security(一種用於Apache /主機環境的防火牆)引起的。 我已經與我的共享主機聯系,並在他們回復時更新答案。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.