Remember Me
forgot your password?

Upload Image Without Refresh Page - Asynchronous Image File Upload Without Ajax


Through concept such as Ajax and scripting languages like PHP, we now have a much robust set tools with which to deal with imaging. Thorugh Ajax, we can dynamically load and display images without the rest of the page having to reload, which speeds up the process considerably. We also have more control over what the user sees while the screen or images load. Users are generally understanding of load times, provided that you let them know what is happening. Thorugh Ajax and a little PHP magic, we can help the user's experience be a seamless and enjoyable as possible.

The basic uploading, manipulating and dynamically displaing images using PHP and Ajax.

Uploading Images
I suppose it is neccessary to bring a little bad news to Ajax at this point, it is not possible to process a file upload through the XMLHtrtpRequest Object. The reason of this is that javascript has no access to your computer's file system. While this is somewhat disappointing, there are still ways to perform Ajax-like functionality for this wighout making use of the XMLHttpRequest Object. Clever developeres have discovered that you can use hidden iframes to post a form request, thereby allowing for a image upload wiothout refresh.

I am designing a website with ajax and php. My main target is doing everything without full page refresh. I have done everything completed. I solved it partially using IFRAME.

By setting the iframe's CSS display property to none, the element is persent on the page to be utilized by the upload form, but not visible to the end user. by assiging a name to the iframe tag, you can use the target attribute in the form tag to post the request to the hidden iframe. Once you have the iframe configured, you can perform any uploads you like, and then use Ajax to perform any extra functionality. Consider the following example, which will allow yout to upload an image to a folder of your specification. Consider the code, which will allow you to create application.

An Ajax-enabled file upload system that uses hidden iframes to hide the upload

The code to create form, with a hidden iframe for processing

As you can see, you are using the same functionality and you will now use it to load the recently uploaded image into your

web page dynamically and without a screen refresh. The uploading function will still perform your form submission, but it is now coupled with a function called downloading, which will fire once the process_upload.php script has finished uploading the image (determined by the onload evernt). The doneuploading function takes ther parent frame of the hidden iframe and the fine name as arguments. It then users Ajax to dyanmically load the image the speicified element of ther parent frame.

Im trying to create a page for a picture framing site where users can upload images to see how they would look framed.

Uploading images can be broken down into the three following steps which will be looked at in turn:

* An HTML form with a browse button to allow the client to choose which file to upload
* A script to process the upload, validate the file, name it and place it in the file system
* Lastly a page to advise the client the upload was a success
* Is there a AJAX based solution or PHP based solution to check the filesize a user is trying to upload via a form.
* If the filesize exceeds more than 2 MB we want to give a message to the user that they need to upload a smaller file

size.

You can upload ZIP file of all your images in one shoot. You can upload image using zip file.
* You can create zip file for image, doc file and other file.
* This script find only jpg file uploaded and other file deleted.
* You can set which extension allowed or not allowed using this script uploaded.

Asif Khalyani

I am Asif Khalyani. I am software Engineer. PHP and ajax free script download site phpasks

Rate this Article: 4.4 / 5 stars - 16 vote(s)
Print Email Re-Publish

Add new Comment



Captcha

  • Latest Programming Articles
  • More from Asif Khalyani

Packt Publishing's new 'Ext JS 3.0 Cookbook'

By: Amit Sharma | 13/11/2009
Authored by Jorge Ramon, the Ext JS 3.0 Cookbook contains step-by-step recipes for building impressive rich internet applications using the Ext JS JavaScript library.

GROUP BY IN XQUERY

By: Anuj Tripathi | 13/11/2009
This article will provide you to implement GROUP BY clause in XQUERY with the code.

Java Developers and the power of Java

By: jacklin | 13/11/2009
Article explaining the security steps Java developers can take for JAR files while developing application with Java platform.

Sending SMS Alerts in SharePoint 2010 over Office Mobile Service Protocol (OMS)

By: Virtosoftware | 12/11/2009
Finally it's possible to send SMS directly from SharePoint to mobile phones. This feature was only available in some add-on components before.

Forbidding the Clipboard for the specified process

By: Apriorit Inc. | 11/11/2009
Though the Clipboard is one of the fundamental parts of the Windows operating system, there is little information about how it works, especially in the low level. In this article, I’m going to tell you something about the Clipboard internals by showing how you can forbid access to it.

How to save money from fixing computer?

By: janson | 11/11/2009
Are you familiar with these problems in your computer below? Mysterious errors, crashes and restarts Sluggish internet and download speeds Trouble loading songs, movies and programs Do you tire of frequently bothering friends for help, or worse, paying a professional to fix your computer? Like a car, without regular maintenance computers begin to accumulate errors that cause slowdowns, crashes and even potential system failure.

Learn Java Easily With an IDE

By: Alberto Pareja-Lecaros | 11/11/2009
Want to learn Java even more quickly than you currently are? IDE's are not just for professionals; learn how you can use an IDE to teach yourself Java even more easily, even if you're an absolute beginner! There are many advantages to using an IDE, why torture yourself by using a standard text editor when you can use the power of an IDE to learn Java even more easily?

Benefits of digital photography-why digital photography is booming?

By: hdrmiar | 11/11/2009
This article shows you some benefits of digital photography and makes an outlook of future development of photography.

Easy Ajax Inline Text Edit 2.0

By: Asif Khalyani | 09/09/2008 | Programming
A small piece of javascript reads al SPAN tags, checks if it has class="editText" and a id=. If that is true, it adds a onclick function. That onclick function will create a textfield or input (depending on the size of the editable text). Someone has the ability to edit the field. When the text field is blurred, it will read the contents, and starts a XMLHttpRequest and ‘sends’ the content + fieldname + any set vars to an update file.

Crop Image File Size, Width & Height Using Php Script

By: Asif Khalyani | 03/07/2008 | Programming
Cropping and resizing your images for the Web is a common technique for creating smaller thumbnail images that download quickly.

Ajax Form Validation and Thread-safe Ajax

By: Asif Khalyani | 03/07/2008 | Programming
This is the PHP and AJAX form validation application you can create AJAX and PHP: Building Responsive Web Applications.

Upload Image Without Refresh Page - Asynchronous Image File Upload Without Ajax

By: Asif Khalyani | 23/06/2008 | Programming
I suppose it is neccessary to bring a little bad news to Ajax at this point, it is not possible to process a file upload through the XMLHtrtpRequest Object. The reason of this is that javascript has no access to your computer's file system.

Submit Your Articles Free: Signup
Article Categories




Use of this web site constitutes acceptance of the Terms Of Use and Privacy Policy | User published content is licensed under a Creative Commons License.
Copyright © 2005-2008 Free Articles by ArticlesBase.com, All rights reserved. (0.03, 0, w1)