473,386 Members | 1,793 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to upload a image using ajax

Hi all

I'm new in ajax. How to upload a image using ajax..

Jul 28 '06 #1
3 20028
Senthil wrote:
I'm new in ajax. How to upload a image using ajax..
If you use an XML HTTP request to POST a request body that is the same
as the type of POST that a form would send when uploading an image file
then any image data in that body would be 'upload'.

The odds are that your issue will turn out to be the
difficulty/impossibility of getting an image file (and its contents)
from the user's hard disk and transforming it into a form that could be
the body of an XML HTTP request.

Richard.

Jul 28 '06 #2
Hi Richard..

I created some example pages to send data's through XML HTTP request.
Same way i try to upload a image using ajax through XML HTTP request. I
try to get the uploaded image details through PHP $_File() request.
But i did not get any information about the uploaded image..

Help me to send a sample code to my email id se*************@gmail.com
for upload image using Ajax XML HTTP request.

Thanks,

Senthil
Richard Cornford wrote:
Senthil wrote:
I'm new in ajax. How to upload a image using ajax..

If you use an XML HTTP request to POST a request body that is the same
as the type of POST that a form would send when uploading an image file
then any image data in that body would be 'upload'.

The odds are that your issue will turn out to be the
difficulty/impossibility of getting an image file (and its contents)
from the user's hard disk and transforming it into a form that could be
the body of an XML HTTP request.

Richard.
Jul 28 '06 #3
Senthil wrote:
Hi Richard..

I created some example pages to send data's through XML HTTP request.
Same way i try to upload a image using ajax through XML HTTP request. I
try to get the uploaded image details through PHP $_File() request.
But i did not get any information about the uploaded image..
AFAIK, you can't send files via AJAX due to security issues. You must
in fact submit a form. There are a couple ways to alleviate this

1. create a form and set the 'target' attribute to the name of an
iframe that will handle the upload

<form name="someForm" method="POST" target="hidden_form"
enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="2000000">
<input type="file" name="upload_file">
<submit name="submit" type="submit" value="Submit">
</form>
<iframe name="hidden_form" src="upload_handler.php" height="0"
width="0"></iframe>

Bad part is that this is asynchronous (you can't upload multiple files
at once).

Other solution:
Put the file upload form inside an iframe. This allows asynchronous
uploads, though the browser will typically limit the number of
connections, around 4. See the following screenshot[1].

When I submit the iframe form, it calls a function in the window's
parent (via window.parent) to generate a new iframe form for uploading.
When files are uploaded, javascript is called to load the uploaded
image in the main window.

[1] http://tinyurl.com/fw9ky

Jul 28 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: tathagata | last post by:
how I will upload the image using AJAX and PHP and also I want to know how to store image in database and folder. Please send code. I will waiting for response.
4
by: SammyBar | last post by:
Hi all, I wonder is it possible to upload the content of an <imgfield to a server. The content of the <imgwas downloaded from a web site different from the one it should be uploaded. The image...
4
by: finecur | last post by:
I am working on the project. Here is the work flow. server. The server will do some calculation based on the data in the file and return an image in Jpg format. The returned image will be...
9
by: Steve Poe | last post by:
I work for an animal hospital trying to use PHP to store an animal's dental x-rays to a file server. I can browse for the xray on the local desktop computer then click "Upload Image". This...
3
by: Ken1 | last post by:
Hello, Does anyone know of an easy to implement ajax upload script for php which also has a progress bar. If possible I'd like it to be able to remove already uploaded files and do minor...
3
by: kksandeep | last post by:
i am using this three files to uplod file. i got this file from net but i think these have some error. i am new to this field plz help the script i found is some helpful but not too that i need ...
1
by: kksandeep | last post by:
i am using this three files to uplod file. i got this file from net but i think these have some error. i am new to this field plz help the script i found is some helpful but not too that i need ...
5
by: camphor | last post by:
hi, I have found an upload script in hotscripts and have implemented it into the website, I followed the installation steps to 'give write permissions to php on the upload folder (which is...
11
by: kj | last post by:
I would like to convert a form that currently uses the traditional CGI sequence (i.e. the action associated with the form sends a POST request to a server-side CGI script) to one that uses AJAX to...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.