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

  • Home
  • SEARCH
  • 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 336801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:16:35+00:00 2026-05-12T10:16:35+00:00

I want to have a user select a file and then have php put

  • 0

I want to have a user select a file and then have php put the contents in db. Now the last part (processing the file in php) is easy. But is there a way I can process a user selected file whithout a new page load?

If I use the following:

<FORM ACTION="upload.php" METHOD="post" ENCTYPE="multipart/form-data">
<INPUT TYPE="file" NAME="somefile"><BR />
<INPUT TYPE="submit" NAME="submit" VALUE="Upload">
</FORM>

Page upload.php automaticaly loads after which I can insert the uploaded file in a database.

I would like to use a combination of javascript, php and xajax to process the file. I don’t think something like this is possible:

<FORM ACTION="javascript:xajax_proces_file()" METHOD="post" ENCTYPE="multipart/form-data">
<INPUT TYPE="file" NAME="somefile"><BR />
<INPUT TYPE="submit" NAME="submit" VALUE="Upload">
</FORM>

Because the file is not uploaded when function xajax_process_file() is called. Or is it? I think I do not fully grasp the principle of uploads with javascript, html and php.

Any help and or clarification is much appreciated.

  • 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-05-12T10:16:35+00:00Added an answer on May 12, 2026 at 10:16 am

    It may help to think of this as a two step process.

    First, the user fills in the form and submits it – step one.

    Second ( which is the default action ) the specified target file takes the input from the form and uses it to do whatever. You can almost think of a form “action” as a link – the default action of a link click is to display the result of the link. The same goes for a form action – display the result of a form action.

    Now, it’s possible via JavaScript to disable the default action of an element for a particular event. It is also possible via JavaScript to access a browsers HTTP mechanism to send/receive HTTP request (which is what every page request is – whether from your URL bar or a page link or a Google search result).

    And that is what AJAX in simple terms is – using JavaScript to use a browsers HTTP mechanism to send requests to a web server and possible receive a response back without the use of a traditional click event. You then combine this with the use of JavaScript to “turn off” default actions and instead follow the action specified by you to get information from a server and add it to the page without ever having to refresh the page.

    Many times to prevent the defualt action from taking place for a certain element, you return false in your code. The same goes for your form. Using javascript:

    form.onSubmit = function() {
      blah blah blah.....Use ajax to send the information to the form handler
      return false; //Prevents the defualt action of the submit event
    }
    

    If you are really new to AJAX, I suggest you check out this tutorial and then this one. Lastly, I would recommend using a Javascript framework like jQuery to help you – it is awesome and does alot of great stuff, but also has easy and built in functionality for AJAX.

    Here is another tutorial to do a form submit with no page refresh (uses jquery).

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

Sidebar

Related Questions

I have a user that want to be able to select a textbox and
I have a multiple selection SELECT field which I don't want the end user
I want to open a save file dialog, have the user enter a filename,
I want to have a User Control that takes a collection of People (property
I don't want to have the user install Google Gears so I can show
I'm working on a resource management class and want to have the user provide
I have a multi-user ASP.NET app running against SQL Server and want to have
I have a user control and I want to create a property of type
I have a user control ( gallery.ascx ) and I want to use the
I want to have a text box that the user can type in that

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.