If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Enjoy an ad free experience by logging in. Not a member yet? Register.

Image Upload via AJAX - How to pass file name to server ?

I am trying to upload an image to the webserver using AJAX, but am unable to pass the file name and path to the PHP script on the server side.

This is the HTML with the JavaScript (ImageUpload01.php) which calls the PHP :

Please do not pay much attention to lines in red/bold as those are the scripts that I wrote for testing and did not work.

The same program I wrote to upload images without the use of AJAX and it DID WORK.
And also, I did the exact same logic using AJAX to retrieve database record upon sending a customer ID and it also worked. But image upload in AJAX is giving me problems (just because I don't know how to pass the file name/path ).

IS NOT AN ANSWER! What is not working? The code I gave you does work! What did you do to it? Post the code your say is not working. please

But before you do LOOK at this
showThumbnail('images/'+file.value);" /> This is the folder where I keep my images. Did you change to the folder YOU use? Please look at the code you get and adapt it to your set up. I have no way of knowing your folder name.

In the real world, there should be a way to get the real path name of the image being uploaded, and we don't need to hard code our folder in
onclick="return showThumbnail('c:\test\pics\/'+file.value);"

OK, I did forget to give you the upload ajax code, lol
Here is what your not understanding.

Code:

But before you do LOOK at this
showThumbnail('images/'+file.value);" /> This is the folder where I keep my images. Did you change to the folder YOU use? Please look at the code you get and adapt it to your set up. I have no way of knowing your folder name.

Was the folder on your site, not on your computer and it has to end in a slash '/'.
Also you sent the file/name to a div not the img src.

If you look at this code you will see that you have to have on your site a folder titled js to hold the javascripts and one called uploads to hold the images that you upload.

This is not my code, see the js file. You can add some error messages if you want.
The HTML: