Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File Download

Status
Not open for further replies.

Doyley3731

Programmer
Jun 4, 2008
4
Hi all,

I am a PHP developer but I am a complete idiot when it comes to activex. I really don't know anything about it.

I need to create a button that when a user hits it creates a csv file and automatically saves it on their computer. I have no problem creating the php to generate the csv but I have no idea about the automatic storing. The filename and destination folder will always be constant.

Any ideas?

Thanks!
 
Here's "snipped" code from my javascript to read a local file,
and process the contents.

Believe to write a file the "GET" would be "PUT" ???
...NEW-> PUT-> SEND-> CLOSE

Note: that the file I'm reading is in the same dir/folder as the script,
so no path on it, else path: X:/folder/subfolder/etc/filename.extension

===========================================================
var var_filnam = "my_filein.txt";
var objHttpReq = false;
var httperr_sw = 0;
var httperr_msg = "";

// ********** start function...
function init_http_connection() {

httperr_sw = 0;
httperr_msg = "";
try { // if newer IE
objHttpReq = new ActiveXObject('Msxml2.XMLHTTP');
}
catch(httperr_msg) {
httperr_msg = "";
try { // if older IE
objHttpReq = new ActiveXObject('Microsoft.XMLHTTP');
}
catch(httperr_msg) {
httperr_msg = "Script ERR:(create Local object) " + httperr_msg;
httperr_sw = 9; //stop following error msgs
}
}
}
}
// ********** end function

// ********** start function...
function loadfiledata_click() {

init_http_connection();

if (httperr_sw == 0) {
httperr_msg = "";
try {
objHttpReq.open("GET", var_filnam, false);
}
catch(httperr_msg) {
httperr_msg = "Script ERR: (Local open) " + httperr_msg;
httperr_sw = 9; //stop following error msgs
}
}

if (httperr_sw == 0) {
try {
objHttpReq.send(null);
}
catch(httperr_msg) {
httperr_msg = "Script ERR: Local file not found - " + var_filnam;
httperr_sw = 9; //stop following error msgs
}
}

//more code here to process the files data/etc

objHttpReq.close;
objHttpReq = false; // clear memory storage space

}
// ********** end function
===========================================================
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top