in Education by
On Internet Explorer, the standard HTML file upload form also allows for direct input of the file name (instead of using the file selector dialog). This makes it possible to enter non-existing files. On other browsers (which do not let you do that) I suppose this case can still occur if you delete the file after having selected it. In order to deal with bugs arising from this problem (like this one), I need to add some validation code on the server-side (which is only possible if the request actually goes to the server, of which I am not sure at this point), or on the client-side (which cannot be very straightforward, as you cannot access the actual file from the JavaScript sandbox). Other than that, the only (and possibly best) option seems to be to hide the input box with CSS magic, like GMail does for attachment files. So, what happens when you try to upload a non-existing file? Is there still a POST request being sent? Or will the browser abort, and if it does, how can I detect that? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
I think I figured it out. First of all, it seems to make a difference whether it is just the file that does not exist, or the whole path is incorrect. If only the file is missing, apparently a POST does take place. At least in the case I mentioned (FCKEditor's image upload dialog on WinXP and IE6), the browser does not submit the form at all (so that there is nothing that can be done server-side). It is possible to detect the problem on the client, by not using the normal form submit, but by having an onSubmit handler that stops the submit (returns false) and instead submits the form itself using form.submit(). If the file is missing, there will be an exception. try{ form.submit(); } catch (e){ // show some error message } return false;

Related questions

0 votes
    When you select “Existing guests only” for SharePoint, how can you add a guest to an environment? Is this through the B2B option?...
asked Mar 10, 2021 in Technology by JackTerrance
0 votes
    I writing a function in my form that require user to upload a file, but doesn't necessary have to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    When you upload a CSV file through UI or External Data API, it is recommended to provide the metadata in the format of __________. A. CSV B. JSON C. XML...
asked Nov 1, 2022 in Education by JackTerrance
0 votes
    What happens if you view a new HTML5 form input type in an older browser?...
asked Apr 10, 2021 in Education by JackTerrance
0 votes
    If you have an existing package that doesn't have an .Rproj file, you can use devtools for the use_rstudio ... of R Programming Select the correct answer from above options...
asked Feb 12, 2022 in Education by JackTerrance
0 votes
    What happens when you try to deploy a file with multiple contracts?...
asked Jan 22, 2023 in Technology by JackTerrance
0 votes
    What happens when you create a hardlink to a text file and then you delete the text file? Select the correct answer from above options...
asked Nov 27, 2021 in Education by JackTerrance
0 votes
    It is possible to convert the existing HTML, CSS websites to hybrid apps using PhoneGap. Please select the correct options from below (a)False (b)True...
asked Dec 11, 2020 in Education by Editorial Staff
0 votes
    If I want to hold a Teams meeting and invite “guests,” what happens if I select that only specific domains ... still able to join the Teams meeting from via a link?...
asked Mar 10, 2021 in Technology by JackTerrance
0 votes
    When does JavaScript code appear inline within an HTML file? (a) Between the script tag (b) ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 23, 2021 in Education by JackTerrance
0 votes
    a) Harshita wants to create an HTML form. Which tag should she use to create this form? Her teacher has asked ... plz answer this fast Select the correct answer from above options...
asked Dec 14, 2021 in Education by JackTerrance
0 votes
    select the most as appropriate options from the example of non-impact printer. Select the correct answer from above options...
asked Dec 5, 2021 in Education by JackTerrance
0 votes
    select the most as appropriate options from the example of non-impact printer. Select the correct answer from above options...
asked Nov 26, 2021 in Education by JackTerrance
+1 vote
    Select the incorrect operator form in the following list(== , <> , >= , <=) and what is the reason for the answer?...
asked Nov 8, 2020 in Technology by JackTerrance
0 votes
    how can you insert some other html text file into your one html file? write the tag used for this purpose? Select the correct answer from above options...
asked Nov 28, 2021 in Education by JackTerrance
...