Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 11th, 2011, 01:30 AM
RK RK is offline
Registered User
 
Join Date: Jun 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to RK
Smile Upload an image to server using Javascript+Ajax

hi friends,
i am trying to do something new for my web page.
In this, i am going to upload an image from the user. Before uploading the images, the user can view selected image in a preview.
My Problem is that the mozila fiewfox is not show the complete path when i select an image using <input type="file"..../> tag.
After this, i want to upload this image to a specified folder at server using javascript and ajax.
I can do this using server side coding(C#.net) but I dont want to reload the complete page.
Can u one suggest me any thing.
 
Old October 19th, 2011, 05:52 AM
Registered User
 
Join Date: Oct 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

it is not possible to process a file upload through the XMLHttpRequest object, becouse JavaScript has no access to your computer's file system. But, there are still ways to perform Ajax-like functionality for this task without making use of the XMLHttpRequest object.
This can be done via a hidden <iframe>
create a form and hidden iframe.
The JavaScript function uses the submit() event to sends form data to the iframe.
The PHP script uploads the image file on the server
This second JS function is used to display the image uploaded. It takes the address of the file loaded on the server and adds in a DIV (with "innerHTML") an <img> tag with the image uploaded.
hope it works..!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Upload image-create & save thumbnail-display image angshujit ASP.NET 2.0 Professional 6 July 11th, 2013 10:34 PM
AJAX AsyncFileUpload control - referencing server side controls after upload gorankovski ASP.NET 3.5 Basics 0 March 26th, 2010 04:32 AM
How to: Upload image to server and save image name in db with other form info Clint PHP How-To 1 October 26th, 2009 05:50 AM
Upload file using Ajax Dj Kat Ajax 5 February 3rd, 2008 11:46 PM
how to upload image into sql server database avnishraj23 General .NET 1 December 4th, 2007 02:20 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.