Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.8k views
in Technique[技术] by (71.8m points)

Uploading picture from camera with HTML Form and PHP Script working locally but not on Heroku

I am confronted to an odd problem:
I want to upload a picture from my phone to a PHP Server using an HTML Form.
So I have an HTML form with a file picker that allow the user to use the camera if he/she visits the form with a mobile device or else he/she can just pick a file from the system.

 <input type="file" name="attachment" required accept="image/*" capture>

enter image description here

LOCAL: Everything works fine, I can upload from my camera on mobile / gallery / my pc
On HEROKU Does not work if the file is a picture JUST taken from the camera.
On HEROKU: it works fine if the picture is from my Gallery ( even if it is the previously taken photo ) or a picture from the pc.
In the error case, the PHP script is not even run I got the following error from Heroku just after submitting the form: enter image description here

Here are the logs from Heroku: enter image description here I tried increasing: post_max_size, upload_max_filesize, max_execution_time on .user.ini file. Changes were taken in consideration (checked with phpinfo()) but does not change the error.

I do not think that the PHP scripts is at fault as the script is not even considered when the error occurs, here it is anyway:

$target_dir = "uploads/";
$FileType = strtolower(pathinfo($_FILES["attachment"]["name"],PATHINFO_EXTENSION));
$target_file = $target_dir . generateRandomString() .'.'.$FileType;
if (move_uploaded_file($_FILES["attachment"]["tmp_name"], $target_file)) {
    //Do next stuff with the file

If anyone has the slightest idea of what could be wrong, I would gladly accept some help Thanks for reading :)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...