Home WordpressWordPress cơ bản Bị chặn định dạng attachment wordpress – upload file type restrictions

Bị chặn định dạng attachment wordpress – upload file type restrictions

by admincp

Các định dạng cho phép upload trong wordpress là:

Images

.jpg
.jpeg
.png
.gif

Documents

.pdf (Portable Document Format; Adobe Acrobat)
.doc, .docx (Microsoft Word Document)
.ppt, .pptx, .pps, .ppsx (Microsoft PowerPoint Presentation)
.odt (OpenDocument Text Document)
.xls, .xlsx (Microsoft Excel Document)

Audio

.mp3
.m4a
.ogg
.wav

Video

.mp4, .m4v (MPEG-4)
.mov (QuickTime)
.wmv (Windows Media Video)
.avi
.mpg
.ogv (Ogg)
.3gp (3GPP)
.3g2 (3GPP2)

Nếu bạn upload tệp với định dạng khác vd: .zip, bạn sẽ nhận được cảnh báo:
Sorry, this file type is not permitted for security reasons.

wordpress-allow-all-file-types

Cách đơn giản bạn thêm dòng sau vào wp-config.php

define('ALLOW_UNFILTERED_UPLOADS', true);

Chỉ cho phép một số định dạng files, sử dụng hook upload_mimes thêm đoạn sau vào functions.php

add_filter('upload_mimes', 'custom_upload_mimes');
function custom_upload_mimes ( $existing_mimes=array() ) {
 // add your extension to the array
 $existing_mimes['deb'] = 'application/x-deb';
 // add as many as you like
 // removing existing file types
 unset( $existing_mimes['exe'] );
 // add as many as you like
 // and return the new full result
 return $existing_mimes;
}

Tham khảo trên net mình thấy có một số plugins mimes có thể làm được điều này như:
pjw mime config
Kết quả mình thử upload file video .flv đây, nó không chặn nữa rồi.
allow-any-file-upload-wordpress

Nếu bạn thích bài viết này, hãy ủng hộ chúng tôi bằng cách đăng ký nhận bài viết mới ở bên dưới và đừng quên chia sẻ kiến thức này với bạn bè của bạn nhé. Bạn cũng có thể theo dõi blog này trên TwitterFacebook

Liên hệ

Công ty chuyên Thiết kế website uy tín nhất Miền Bắc: http://vinastar.net

Hotline tư vấn: 0989 48 3456

Nguồn: Sưu tầm trên internet

You may also like

Leave a Comment