WishYouWould Posted August 5, 2022 Share Posted August 5, 2022 (edited) Source code : https://github.com/onlylegendleft/upload environment : https://eternalvale.xyz/dnd/upload/ error : none problem : It is not uploading to server. what I think the problem is : something to do with how the data is being posted.https://stackoverflow.com/questions/8893574/php-php-input-vs-post Edited August 5, 2022 by WishYouWould Quote Link to comment https://forums.phpfreaks.com/topic/315145-php-upload-error/ Share on other sites More sharing options...
mac_gyver Posted August 5, 2022 Share Posted August 5, 2022 there's no field named submit in the form, and even if there was, it won't be included in the form data since it isn't a successful form control at the time the form was submitted, since the form is being submitted via an on change event. i recommend that you instead detect in the php code if a post method from was submitted. i also recommend that you log the $_POST and $_FILES data at the start of the php code so that you can see what is being submitted. none of this has anything to do with the linked to stack overflow thread. also in the php code, if the total size of the form data exceeds the post_max_size setting, both the $_POST and $_FILES arrays will be empty. after you have detected if a post method form was submitted, you must detect this condition and setup a message for the user that the form data was too large and could not be processed. if there is $_FILES data, you must then test the ['error'] element before using any of the uploaded file information. the ['error'] element will be a zero if the file successfully uploaded and can be processed. lastly, since you are using ajax to upload the file, nothing the upload.php file does in the way of redirecting will have any affect on the web page being displayed in the browser. you would want to output failure or success messages back to the ajax code to be displayed in the browser. Quote Link to comment https://forums.phpfreaks.com/topic/315145-php-upload-error/#findComment-1599049 Share on other sites More sharing options...
WishYouWould Posted August 6, 2022 Author Share Posted August 6, 2022 Understood. We dont want to use ajax, so were going to revert to a previous working version. Quote Link to comment https://forums.phpfreaks.com/topic/315145-php-upload-error/#findComment-1599051 Share on other sites More sharing options...
mac_gyver Posted August 6, 2022 Share Posted August 6, 2022 the php code still needs the described post method form test, post max size checking, and ['error'] element testing in order to provide a good User eXperience (UX). Quote Link to comment https://forums.phpfreaks.com/topic/315145-php-upload-error/#findComment-1599055 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.