I want the start_uploading function only to start if all the conditions are met and the file is uploading, right now the ‘loading’ message pops up for a split second when the form is submitted but it did not meet all the conditions to upload.
if(condtion){// don't start function} else
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) {
//now start function} else echo "error";
javascript
function start_Uploading(){
document.getElementById('message').innerHTML = 'Loading... <br> Please Wait';
return true;
}
and html
<form action="something.php" method="POST" enctype="multipart/form-data"
onsubmit="start_Uploading();">
Since you are checking for the condition to be true in php, I would simply only echo out the js method name if the condition is met.
Like so:
And then in your form:
If the condition isn’t met, no method name will be provided and js simply won’t know what to look for on submit.