php - Cakephp file upload problem -


I am using Cakephp as my framework in uploading my files through a form I have a problem. I am using an uploader plugin from the website.

This is the piece of code in my php ini file.

  upload_max_filesize = 10M post_max_size = 8M  

this is from uploader.php -> in the plugin file

  $ var MaxFileSize = '5M'; // default max file size  

In my controller.php file, I use this code to set the maximum file size in runtime as 1 MB.

  function BeforeFilter () {Origin: FirstFilter (); $ This- & gt; Uploader-> MaxFileSize = '1M'; }  

In the uploader.php, we do this ...

  if (empty ($ this-> maxFileSize)) {$ this - & gt; Max file size = ini_get ('upload_max_filesize'); // mile 1} $ byte = pre__reley ('/ [^ 0- 9] / i', '', $ this-> maxfile size); $ Last = $ this- & gt; Bytes ($ this-> maxFileSize, 'byte'); If ($ last == 't' || $ final == 'TB') {$ multiplier = 1; $ ExecTime = 20; } And if ($ last == 'g' || $ last == 'GB') {$ multiplier = 3; $ ExecTime = 10; } And if ($ last == 'm' || $ final == 'MB') {$ multiplier = 5; $ ExecTime = 5; } And {$ multiplier = 10; $ ExecTime = 3; } Ini_set ('memore_limit', ($ $ byte * $ multiplier) * $ multiplier) last $); Ini_set ('post_max_size', ($ byte * $ multiplier). $ Last); // Error here in__set doubt ('upload_tmp_dir', $ this- & gt; tempDir); Ini_set ('upload_max_filesize', $ this- & gt; maxFileSize); Expected Result: When I try to upload a file which is 2 MB in size, it should not be because maxFileSize is 1 MB in run time. Therefore uploading should fail.  

The problem is: But this is being uploaded.

Landmark 1 is not executed (In comments) ... Land mark 2 does not work ... upload_max_filesize does not get value from maxFileSize

Please help me ... Thank you Setting upload_max_filesize during script execution, is rather meaningless, because before the script file is executed The file has been uploaded and approved by the server. If you need to reject the file based on size in your script (as opposed to rejecting Apache or PHP), you can evaluate the size of the uploaded file If required and if it is too large, then ignore it manually.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -