PHP post_max_size issue
Khanh is a full stack web developer with over 15 years of experience developing for the web
Search for a command to run...
Khanh is a full stack web developer with over 15 years of experience developing for the web
No comments yet. Be the first to comment.
Elevate your bus reservation experience (or even movie, theater, train, ship, plane tickets) with the React Bus Seat Map Picker – a sophisticated and meticulously crafted script designed exclusively for bus seat bookings. Engineered with strict TypeS...

In previous blog, I migrated all posts from my WordPress to Hashnode at https://blog.donamkhanh.com. Now I create a simple landing page for my main domain and hosted on Github Page. You can access at https://donamkhanh.com. In feature, I'm going to h...

I just finished migrating my blog from Wordpress (self hosted on DigitalOcean) to Hashnode. How did I migrate? I don't have too many articles on Wordpress but I don't like doing it manually so the first thing I did was look to see if there was an aut...

Dự án mình đang làm có yêu cầu sử dụng Azure Active Directory (AAD) để lưu trữ thông tin người dùng & xác thực đăng nhập các kiểu. Ngoài các trường thông tin cơ bản mà AAD hỗ trợ ra thì dự án mình cần lưu thêm 1 số thông tùy chọn khác cho người dùng....

Introduction This is a concise front-end application developed with Angular. You can create a beautiful form with drag and drop visualization. You can get inspiration from it to make a draggable form; at the same time, you can also modify it to suit ...

Hôm nay tôi gặp phải 1 "tình huống" khá là củ chuối. Phần upload file (thật ra là upload file để update lại các store - khá nhiều, hiện tại là 1500 store) có validate file size, file type. Tôi test "khá kỹ " ở local & mọi thứ đều ổn. Thông số local của tôi như sau:
Khi up 1 file có dung lượng quá 20MB (<100MB) thì hệ thống hiện thông báo rất đẹp với nội dung là bạn đã upload quá dung lượng quy định bla bla...:-@
Thế nhưng sau khi request done trên PMS (project management system), bên test report lại là khi upload 1 file lớn hơn 16MB thì chẳng hiện gì cả, không lỗi & giống như tự F5 lại trang.
Xem phpinfo của môi trường trên testing thì như sau:
Vậy là dung lượng vượt quá post_max_size rồi, và PHP đã làm thế này đối với đoạn code của tôi:
If the size of post data is greater than post_max_size, the $_POST and $_FILES superglobals are empty
Thế cho nên đoạn code:
$postMaxSize = int_get('post_max_size'); if($postMaxSize < $userFile['size']) { //process error }
chẳng hoạt động gì cả :(( Trên php.net có 1 trick để xử lý trường hợp này:
This can be tracked in various ways, e.g. by passing the $_GET variable to the script processing the data, i.e.
, and then checking if $_GET['processed'] is set.
Và đây là đoạn code của tôi:
if(isset($_GET['processed']) && !count($_POST)) { die('Error message here...'); }
Chạy ngon ;)
Rất cảm ơn anh NBThanh (Nguyễn Bá Thành) đã giúp đỡ em khắc phục vấn đề này :)