473,385 Members | 1,311 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,385 software developers and data experts.

Download of file through javascript anonymously without knowledge of user

Hi All,

I have one requirement...

Its like a search engine design.

I will have a text box to type in the search text and a search button on clicking which the search action should take place.

I need to download a text file from the server to the user machine on clicking the search button and i have to do some manipulation by reading the contents of that downloaded text file ... But download of file should happen anonymously without the knowledge of user..

Please help me...

Thanks in advance...
Sep 8 '07 #1
7 1856
acoder
16,027 Expert Mod 8TB
Changed the thread title to add more information.

Why not do the manipulation on the server-side? Why is it necessary to download the file?
Sep 8 '07 #2
pbmods
5,821 Expert 4TB
Heya, ponvijaya.

Honestly, would YOU want a website to be able to download and open a file on your computer without your knowledge?
Sep 8 '07 #3
Assuming that you're trying to provide information to the user while they're typing or just after clicking the search button, you should look at Ajax as a technique. This allows you to retrieve information -- not to save it as a file, but to retrieve it and then to parse it. This is similar to what Google does when typing to suggest terms you may want to search for.
Sep 9 '07 #4
rnd me
427 Expert 256MB
here a simple way to download a text file:

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. function IO(U, V) {
  4. X = !window.XMLHttpRequest ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest;
  5. X.open(V ? 'PUT' : 'GET', U, !1);
  6. X.setRequestHeader('Content-Type', 'text/html')
  7. X.send(V ? V : '');
  8. return X.responseText;}
  9.  
  10. alert(IO("text1.txt"));

to save a text file with the contents of a string:
Expand|Select|Wrap|Line Numbers
  1. IO("text1.txt", "hello world this is javascript")
Sep 9 '07 #5
pbmods
5,821 Expert 4TB
Heya, Rnd.

Please use CODE tags when posting source code:

[CODE=JavaScript]
JavaScript code goes here.
[/CODE]
Sep 9 '07 #6
rnd me
427 Expert 256MB
Heya, Rnd.

Please use CODE tags when posting source code:

Expand|Select|Wrap|Line Numbers
  1. JavaScript code goes here.
  2.  
well i had tried, but i hate the line number that get inserted when any of the code formats are applied; it makes it hard to cut and paste!

is there a way around the problem?
Sep 9 '07 #7
pbmods
5,821 Expert 4TB
Heya, rnd.

is there a way around the problem?
Simply click the 'Reply' button, and you can copy the code without line numbers.
Sep 9 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Jim Willsher | last post by:
Hi all, PHP 4.2.2 on RedHat9 I have some files on my website for people to download, and I want to generate the file location "on the fly", so the URL is held in a database. I have a simple...
3
by: James Kirk | last post by:
The script below allows me to link to a file and as the user clicks to download, the 'File Download' windows appears as normal, and the user can download... The original page is then redirected...
3
by: Michael | last post by:
I am trying to allow a user to view a PDF in a new window. I currently have this working using the following: <a href="./pdf.do?parameter=01121980" target="top"><b>pdf</b></a> The problem...
6
by: chon | last post by:
I have an ASP page that is sent a file location as a parameter. It opens this file, loads the ADODB.Stream object and does a binary write to the page forcing the download dialog to appear. This...
6
by: Glenn Owens | last post by:
As a "newbie" to Javascript I need some help with my latest problem... I have a number of image files that have been pre-selected by the user for downloading. I'd like to be able to have the user...
4
by: Kevin Muenzler, WB5RUE | last post by:
How do I force a browser to download a file instead of displaying it? In other words I have a page with MP3 and WMA files on it and I would like for the visitor to download the file instead of...
6
by: JCO | last post by:
Does anybody have a Download Dialog written in JavaScripts? This is for a website. I've seen it done before.... where you click on what you want and the dialog comes up asking you if you want to...
3
by: Skwish | last post by:
Hi, I would like to download all the files from a folder (of various types i.e. ..txt, .dll, .dat, etc.). I tried Dim MyDir As IO.Directory Dim path As String = Me.MapPath(".") & "\Data" Dim...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.