Page 1 of 1
downloading .exe, opening it;
Posted: Thu Mar 11, 2004 10:47 am
by dsdsdsdsd
hello;
four part question:
with the press of a <form type="submit"> :
1) I want to download a .exe from url="this_url" to directory "this_dir";
2) once downloaded I want the .exe to be opened into directory "this_dir/its_subdir";
3) in ".. its_subdir" will be .csv files whose file names I should array collect;
4) each .csv will be opened, processed, and sent to a MySQL table;
# 1) and 2) are my problems;
I am looking through the php manual at the 'header' functions, 'socket' functions, 'stream' functions;
am I in the right direction?
thanks
Shannon Burnett
Asheville NC USA
Re: downloading .exe, opening it;
Posted: Thu Mar 11, 2004 11:14 am
by TheBentinel.com
dsdsdsdsd wrote:1) I want to download a .exe from url="this_url" to directory "this_dir";
You have a file on your server at this_url that you want to download to the user, dropping it on his machine in this_dir, is that correct?
You can change the action of your form tag to this_url and it would initiate the download (I think), but you wouldn't be able to control where the file went on the user's machine. You might be able to influence it, but you couldn't force it. (I'm not even sure that you can influence it.) That "change the action to this_url" is hacky and surely not what you want to do. You could more easily accomplish it with a link to the download file. However you get it to the user, though, he'll control where it drops on his system.
dsdsdsdsd wrote:
2) once downloaded I want the .exe to be opened into directory "this_dir/its_subdir";
Once the file is downloaded, the browser will offer to open the file for the user, if the user has his browser configured that way. If your file is a self-extracting EXE, you can probably set up the intended extraction path, though the user can probably override that, too.
You don't have much (any, really) control over files once the user has downloaded them.
Posted: Thu Mar 11, 2004 11:52 am
by dsdsdsdsd
hello Dave;
1) amended: I, system administrator, want to download a .exe from url="UPS.com/..." to directory "my_dir_on_my_server";
2) amended: once .exe is in "my_dir_on_my_server" I want the .exe to be opened(lots of .csv files are either in it ) into directory "my_dir_on_my_server/subdir";
Posted: Thu Mar 11, 2004 12:05 pm
by TheBentinel.com
dsdsdsdsd wrote:
1) amended: I, system administrator, want to download a .exe from url="UPS.com/..." to directory "my_dir_on_my_server";
2) amended: once .exe is in "my_dir_on_my_server" I want the .exe to be opened(lots of .csv files are either in it ) into directory "my_dir_on_my_server/subdir";
So, all of the processing that you want to do should happen client-side? You want to pull a file from UPS.com (or wherever), drop it on your local system that's running the browser, and then execute the file?
So you're looking for more of a javascript thing than a PHP thing?
I'm sorry, I'm probably still not getting it. If you want to try to enlighten me further, I really will try to help.
Posted: Thu Mar 11, 2004 1:22 pm
by dsdsdsdsd
no, not javascript, because UPS.exe will be downloaded from UPS.com onto my server via a server-side script, the.php, into public_html folder;
thus browsers will not be involved, EXCEPT that a system admin will initiate the process from
http://www.domain.com/the.php which will have a <form type="submit">;
so, php;
also, step 4) is exclusively server-side scripting, which frankly is the reason I focused on php for this task;
Posted: Thu Mar 11, 2004 1:29 pm
by TheBentinel.com
dsdsdsdsd wrote:no, not javascript, because UPS.exe will be downloaded from UPS.com onto my server via a server-side script, the.php, into public_html folder;
thus browsers will not be involved, EXCEPT that a system admin will initiate the process from
http://www.domain.com/the.php which will have a <form type="submit">;
so, php;
also, step 4) is exclusively server-side scripting, which frankly is the reason I focused on php for this task;
Ah, ok. Can you retrieve the file with file_get_contents? Not sure if it works on binary files.
Code: Select all
// go get the file
$url = "http://UPS.com/ups.exe";
$EXEfile = file_get_contents($url);
// write it back out
$fp = fopen($my_dir, "w");
fwrite($fp, $EXEfile, strlen($EXEfile));
fclose($fp);
Try it out, I'm not at all sure that will work.
Ah, but now running the EXE? I assume your server is a Windows machine and so you'll be able to execute an EXE file? Then could you run it with the passthru command?
Code: Select all
$output = passthru("C:\public_html\ups.exe");
print ($output);
Still not sure how you'd tell it where to unpack the files to, though.
And not at all sure any of this will even work. But maybe it will put you on the right track.