Jump to content

Recommended Posts

I attempted to perform a file upload via Ajax and avoid the problems of a postback, but I finally got too tired and just went the normal form-postback route.  The problem is, in my case, you are uploading photos which are to be linked (or inserted) to a selected row of a visual representation of an sql table.  Of course, after the postback the selected table row (along with all other fields) are reset and I have no way of knowing which record to associate the uploaded file to.  Help.

 

This is my first posting on this site and I'm fairly new to this whole PHP, Javascript, AJAX stuff.

Link to comment
https://forums.phpfreaks.com/topic/53884-file-uploadingpostback/
Share on other sites

Ok... I found one way to get around the problem.  After hitting the browse button, but before hitting the Upload (submit) button, I am able to save the values I need in elements (hidden or not) that are contained in the form, then retrieve them later in the PHP code via $_POST['elem_name'].  Is this the "normal" way to go about this when you are forced to do a submit/postback?  Since I am doing a lot of ajax stuff (using xmlHttp) which seems to make things prettier for the user, and easier for the programmer.  This file upload deal was the 1st time I was really forced to do the POST.

so now i am shoving values i need to save in hidden fields in the form to be submitted (the form that includes the file upload element).  great.  now, upon reload/postback, i cant fetch those values in PHP, but now I need to feed them back into the original HTML elements (via Javascript I would think).  My head hurts.  I'm really getting closer and closer to understanding this stuff and would prefer to not just patch in some mystery php/ajax upload code.  any help would be greatly appreciated.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.