Hey, I got this Script:
It basically checks the extensions via jScript and alerts the user. If its all good, it submits the form and away goes the upload.
Zoom in on this script:
When the return true; is on the top, it submits the form and it uploads away =)
But it doesnt do the other 2 lines below it.
But if i switch the code around like so:
It will change the uploadbutton (uploadbut) to the upload sign and disable it.
But then it doesn't return it as true!?
The weird thing is that it Submits the form, but it doesnt upload the file? I'm guessing my PHP doesn't register that it was a POST function without it being 'true'.
Any help would be awesome.
Thanks.
| Code: |
| function Upload() {
var ex = document.getElementById('ext').value extArray = ex.split(", "); var file = document.getElementById('file').value allowSubmit = false; if (!file) return false; while (file.indexOf("\\") != -1) file = file.slice(file.indexOf("\\") + 1); ext = file.slice(file.indexOf(".")).toLowerCase(); for (var i = 0; i < extArray.length; i++) { if (extArray[i] == ext) { allowSubmit = true; } } if (allowSubmit == true) { return true; document.getElementById('uploadbut').disabled = 'true' document.getElementById('uploadbut').value = 'Uploading..Please wait' } else { alert("Please only upload files that end in types: " + (extArray.join(" ")) + "\nPlease select a new " + "file to upload and submit again."); return false; } } |
It basically checks the extensions via jScript and alerts the user. If its all good, it submits the form and away goes the upload.
Zoom in on this script:
| Code: |
| if (allowSubmit == true) {
return true; document.getElementById('uploadbut').disabled = 'true' document.getElementById('uploadbut').value = 'Uploading..Please wait' } |
When the return true; is on the top, it submits the form and it uploads away =)
But it doesnt do the other 2 lines below it.
But if i switch the code around like so:
| Code: |
| if (allowSubmit == true) {
document.getElementById('uploadbut').disabled = 'true' document.getElementById('uploadbut').value = 'Uploading..Please wait' return true; } |
It will change the uploadbutton (uploadbut) to the upload sign and disable it.
But then it doesn't return it as true!?
The weird thing is that it Submits the form, but it doesnt upload the file? I'm guessing my PHP doesn't register that it was a POST function without it being 'true'.
Any help would be awesome.
Thanks.
