php - File upload form does not work with large files -


i have pretty standard upload form. few text inputs, file upload input, recaptcha, , submit button.

under normal use, can upload small file fine. form data redirected page in action attribute, , while bunch of things done in php , sql handles uploads.

however, when trying upload 40 mb file, not work. @ first, thought captcha, since gave me errors failing type in correct words. after disabling captcha, found variables defined $_post['input'] not being passed through. php errors such as:

notice: undefined index: name in /var/www/upload.php on line 18 

where line 18 $name=$_post['name'];

i 1 of these every input in form.

this telling me post not being set because form not working when sending large files, question simply...why? , of course, what's solution?

edit: relevant code:

submit form:

<form action="/upload.php" method="post" enctype="multipart/form-data">     <ul>         <li>             <input class="text" type="text" name="name">         </li>         <li>             <input class="text" type="email" name="email" placeholder="<?php echo $content['submitformemailplaceholder'];?>">         </li>         <li>             <input type="file" name="file">             <input class="text" type="text" name="url" placeholder="http://">         </li>         <li>             <textarea class="text" name="notes" rows="5"></textarea>         </li>         <li>             <?php                 require_once($_server['document_root'].'/resources/recaptchalib.php');                 $publickey = "key";                 echo recaptcha_get_html($publickey);             ?>         </li>         <li>             <input type="submit">         </li>     </ul> </form> 

upload code:

<?php     date_default_timezone_set('utc');     //echo $_files['file']['error'];     require_once($_server['document_root'].'/resources/recaptchalib.php');     $privatekey="key";     $resp=recaptcha_check_answer($privatekey,$_server["remote_addr"],$_post["recaptcha_challenge_field"],$_post["recaptcha_response_field"]);     if(!$resp->is_valid){         echo "<h1>".$content['uploaderror']."</h1>".$content['uploadcaptcha']."<br><br>".$content['uploadreturn'];     }else{         $name=$_post['name'];         $email=$_post['email'];         if(empty($name)){             echo "<h1>".$content['uploaderror']."</h1>".$content['uploadname']."<br><br>".$content['uploadreturn'];         }elseif(empty($email)){             echo "<h1>".$content['uploaderror']."</h1>".$content['uploademail']."<br><br>".$content['uploadreturn'];         }else{             $url=$_post['url'];             $notes=$_post['notes'];             $timedate=date('ymdhis');             $dbhandle=new pdo("mysql:host=localhost;dbname=upload;","user","password",array(pdo::attr_emulate_prepares => false));             $dbhandle->setattribute(pdo::attr_errmode, pdo::errmode_exception);             $query=$dbhandle->prepare("insert `data` (approved,name,email,fileid,url,notes,timedate,viewcount) values(?,?,?,?,?,?,?,?)");             $types=array(                 'jpg','jpeg','gif','png',                 'mp3','wma','wav','ogg','aac','flac',                 'avi','wmv','mov','ogg','webm','mpg','mpeg','mp4'             );             $filechk=(isset($_files['file']) && !empty($_files['file']['name']));             $urlchk=(isset($url) && !empty($url));             if(!$filechk ^ $urlchk){                 echo "<h1>".$content['uploaderror']."</h1>".$content['uploadfileurl']."<br><br>".$content['uploadreturn'];             }elseif($filechk){                 $filesize=(75*1024*1024);                 $up_path=$_server['document_root'].'/resources/uploads/';                 $filename=$timedate.$_files['file']['name'];                 $ex=explode(".",$filename);                 $ext=strtolower(end($ex));                 if(file_exists($up_path.$filename)) {                     $filename=$timedate.'duplicate.'.$ext;                 }                 if(!in_array($ext,$types)){                     echo "<h1>".$content['uploaderror']."</h1>".$content['uploadfiletype']."<br><br>".$content['uploadreturn'];                 }elseif(filesize($_files['file']['tmp_name'])>$filesize){                     echo "<h1>".$content['uploaderror']."</h1>".$content['uploadfilesize'].($filesize/1024/1024)." mb<br><br>".$content['uploadreturn'];                 }elseif(!is_writable($up_path)){                     echo "<h1>".$content['uploaderror']."</h1>".$content['uploadwriteerror']."<br><br>".$content['uploadreturn'];                 }elseif(move_uploaded_file($_files['file']['tmp_name'],$up_path.$filename)){                     $fileid=$filename;                     $url=null;                     $query->execute(array('n',$name,$email,$fileid,$url,$notes,$timedate,'0'));                     echo "<h1>".$content['uploadsuccess']."</h1>".$content['uploadhomepage'];                 }else{                     echo "<h1>".$content['uploadunknownerror']."</h1>".$content['uploadreturn'];                 }             }else{                 $fileid=null;                 $query->execute(array('n',$name,$email,$fileid,$url,$notes,$timedate,'0'));                 echo "<h1>".$content['uploadsuccess']."</h1>".$content['uploadhomepage'];             }         }     } ?> 

try , increase upload_max_filesize , post_max_size in php.ini file. set them both 50m sure.

you should restart apache after changing this, too. depends on setup, replace pathtoapache path apache on server;

sudo /etc/pathtoapache/apache2 restart 

apache start/restart/stop docs.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -