php - AWS Elastic Beanstalk file upload not working -
we use aws elastic beanstalk host php applications include file upload facilities aren't working. have php.ini set tmp_upload_dir /tmp still doesn't work.
we've moved site server, working there, eb doesn't seem want let upload files.
here's example of code using:
$imagepath = "/tmp/"; $allowedexts = array("gif", "jpeg", "jpg", "png", "gif", "jpeg", "jpg", "png"); $temp = explode(".", $_files["img"]["name"]); $extension = end($temp); if ( in_array($extension, $allowedexts)) { if ($_files["img"]["error"] > 0) { $response = array( "status" => 'error', "message" => 'error return code: '. $_files["img"]["error"], ); echo "return code: " . $_files["img"]["error"] . "<br>"; } else { $filename = $_files["img"]["tmp_name"]; list($width, $height) = getimagesize( $filename ); move_uploaded_file($filename, $imagepath . $_files["img"]["name"]); $response = array( "status" => 'success', "url" => $imagepath.$_files["img"]["name"], "width" => $width, "height" => $height ); } } else { $response = array( "status" => 'error', "message" => 'something went wrong', ); }
i had same problem, , found needed 2 things, both of put .htaccess file:
php_value upload_tmp_dir "/tmp" php_value upload_max_filesize 10m
the upload directory must owned web server, e.g. "webapp", or "daemon", or writable account. in addition, max filesize must accommodate uploads.
in case, upload limit 2m default, , files 4m. resulted in empty $_files array.
This comment has been removed by the author.
ReplyDeleteNice blog post on AWS
ReplyDeleteAWS Training in Chennai | AWS Training Institute in Chennai | Best AWS Training in Chennai | AWS Training Class in Chennai | AWS Training Center in Chennai