是否可以允许在Wordpress中上载zip文件?
我有以下代码,但它不工作。
function custom_upload_mimes($existing_mimes = array()) {
// Add *.EPS files to Media upload
$existing_mimes[\'eps\'] = \'application/postscript\';
// Add *.AI files to Media upload
$existing_mimes[\'ai\'] = \'application/postscript\';
// Add *.AI files to Media upload
$existing_mimes[\'3ds\'] = \'application/postscript\';
// Add *.dwg files to Media upload
$existing_mimes[\'dwg\'] = \'application/acad\';
// Add *.dwg files to Media upload
$existing_mimes[\'dwg\'] = \'application/x-acad\';
// Add *.dwg files to Media upload
$existing_mimes[\'dwg\'] = \'application/autocad_dwg\';
// Add *.dwg files to Media upload
$existing_mimes[\'dwg\'] = \'application/dwg\';
// Add *.dwg files to Media upload
$existing_mimes[\'dwg\'] = \'application/x-dwg\';
// Add *.dwg files to Media upload
$existing_mimes[\'dwg\'] = \'application/x-autocad\';
// Add *.dwg files to Media upload
$existing_mimes[\'dwg\'] = \'drawing/dwg\';
//add .zip
$existing_mimes[\'zip\'] = \'application/zip\';
return $existing_mimes;
}
add_filter(\'upload_mimes\', \'custom_upload_mimes\');
最合适的回答,由SO网友:Pontus Abrahamsson 整理而成
以下是在我的网站上有效的操作:
add_filter(\'upload_mimes\', \'custom_upload_mimes\');
function custom_upload_mimes ( $existing_mimes=array() ) {
// add your extension to the mimes array as below
$existing_mimes[\'zip\'] = \'application/zip\';
$existing_mimes[\'gz\'] = \'application/x-gzip\';
return $existing_mimes;
}