Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Ajax
|
Ajax the combination of XHTML, CSS, DOM, XML, XSLT, XMLHttpRequest, and JavaScript
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Ajax 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 March 21st, 2006, 08:38 AM
Friend of Wrox
 
Join Date: Nov 2005
Posts: 223
Thanks: 0
Thanked 0 Times in 0 Posts
Default Upload file using Ajax

Hi,

Is it possible to use Ajax to upload a file.
I need to upload a file and put data in a datbase.

thnx

__________________________________________________ ________
This is my junk I'm gona eat it
 
Old March 21st, 2006, 08:53 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

As with most questions the answer is yes and no.
In an intranet application, where the browsers security settings allow access to the user's drive, then you can read a file, embed the data as base 64 encoded binary into an XML file. We had an application like this at my last company.

For examples of doing this search the forums for posts by joefawcett with adodb.stream in the message.

The disadvantage is that large files get very large when encoded.

Alternatively you can just use the standard input, type=file, control to upload with the user's acceptance and maybe post some extra information back via Ajax as well.


--

Joe (Microsoft MVP - XML)
 
Old March 25th, 2006, 05:41 PM
Friend of Wrox
 
Join Date: Nov 2005
Posts: 223
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thnx imformation joefawcett,

I'll have a go to try this method. The thing is that this method would be very handy to use with a cms.



__________________________________________________ ________
This is my junk I'm gona eat it
 
Old March 25th, 2006, 11:03 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

I solved this in an application of mine by posting the form containing the file input field to a hidden iframe. It gives the impression of being AJAX, while it's just a standard file input that's posting to a hidden frame.

Regards,
Rich

--
[http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design
 
Old November 12th, 2007, 07:13 AM
Registered User
 
Join Date: Nov 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello to all,
   can u please tell me how to do upload files with iframe.i want upload process something like GMAIL.i m using Majix:Ajax Panel in my Page..


Please Help Me.....

 
Old February 3rd, 2008, 11:46 PM
Authorized User
 
Join Date: Jun 2007
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi panchalvimal

Place a hidden IFrame in your main page and load an HTML form, containing upload control on it. When user wants to select a file, call 'click()' method of your file upload control that exists in hidden iframe from your container page. This would bring a choose file dialog so that user can select a file.

After that, when you want to start uploading, call 'submit()' method of form element from your container page. This will starts uploading HTML page, contained in hidden iframe. When upload completes, your response would be placed in hidden iframe. You should place upladed file in a temporary location (like user session or a temporary folder on your server) and generate an appropriate javascript code on your response, so that when response loads completely on your client page, makes a call to container and inform it about upload completion.

Goodluck

Ehsan Zaery Moghaddam





Similar Threads
Thread Thread Starter Forum Replies Last Post
File Upload Using Ajax panchalvimal ASP.NET 2.0 Professional 2 November 13th, 2007 07:24 AM
Filter File Types in ASP.NET File Upload ramuis78 ASP.NET 2.0 Basics 2 May 31st, 2007 10:50 AM
Uploading a file using AJAX stephy ASP.NET 1.0 and 1.1 Professional 1 December 12th, 2005 04:39 PM
Whole Folder upload(Multi file Upload) ramasamy_rams XML 1 September 9th, 2005 12:43 PM
JSP file upload and delete file pandjie JSP Basics 0 January 29th, 2005 10:49 PM





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