0

My question is plain and simple, I am trying to upload an image without a page refresh.

I have looked around the net, and yes, there are quite a few examples. Although, most of them are not what I am after. Some of them still refresh the page. Some preview the image and have a fancy uploader. I am not after anything of this kind.

I have a HTML form with a file browse. Once the user has selected their image, and the submit button is pressed, the image gets saved to the 'uploads/' section in my server.

I have found that the best ways to do this are via AJAX, PHP and through an iFrame. Although, most examples online are either not working at all, or are far to complex.

THIS IS AN ASSIGNMENT. But my teacher has stated that we can use any upload script we find online, as long as we reference it.

I am limited to Javascript (no librarys such as jquery, just plain javascript), PHP, HTML and AJAX.

All help is greatly appreciated, and I am open to all links that you provide also, since I may have missed a few.

Thanks!

4

1 回答 1

0

Use, "new FormData()" and send it via Ajax. That's only works on modern browsers, if you want to support IE, use a hidden iframe as target to your form and handle it using javascript.

于 2013-03-31T03:36:00.193 回答