Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8486389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:56:01+00:00 2026-06-10T20:56:01+00:00

I have a html form used to upload file to the server. For brevity,

  • 0

I have a html form used to upload file to the server. For brevity, I have only shown the essential peices

 <form id='uploadform' method='post' enctype='multipart/form-data' action='index.php/upload'>
   <input name='myFile' id='myFile' type='file'/>
 </form>
 <input type='button' id='upload' value='Upload'/>
 <div id='response'></div>

I use jQuery.submit() to submit the form:

 $('#uploadform').submit();

Business logic is Slim PHP :
$app->post(‘/upload’, ‘uploadFile’);
….

   function uploadFile(){
       try{
           // if success uploading
           $app->redirect('/main-page');

       }catch(Exception $e){
           // if error 
           echo $e->getMessage();

       }
    }

Issue: If the upload fails for some reason, an exception is thrown, user is taken to a PHP error page. If upload was completed without exception, the application is redirected to main page.

What is required is: if the upload succeeds the application should be redirected to main-page as it does now…but if there was any exception thrown, instead of going to PHP error page, the application should stay on upload page and with id = ‘response’ should display exception.

Is it possible to do anything like this with jQuery submit():

     $('#uploadform').submit(function(response){
           $('response').html(response);
     });

????

I know JQuery upload file plugins would make life easier…but that is not an option for me…

Thanks for any pointers!

Is it possible

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T20:56:02+00:00Added an answer on June 10, 2026 at 8:56 pm

    You need to use ajax here is example for file upload using ajax

    Sending multipart/formdata with jQuery.ajax

    with out ajax you can redirect back user and send error text by GET method and put this text in response tag

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple HTML Form <form id=uploadForm method=post action=/cgi-bin/test.cgi enctype=multipart/form-data> <input type=submit name=add_something
I have a html form <form action=process.php method=post> <input type=checkbox name=name[v1] /> <input type=checkbox
I have a html form and i used it to upload a picture to
I have an HTML form that previously was only used for text attributes for
I have a following problem, I have HTML form that uploads a file with
I have a HTML/PHP form using using post to send form data to a
I have an input form used for a forum, where users can post messages.
I have a file upload form where the file gets uploaded to an S3
I have the HTML form which do prior upload of files via AJAX. So
I have this : HTML : form + jquery Controller I post the form

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.