ThunderAI Posted June 10, 2008 Share Posted June 10, 2008 Now that I was explianed how to download a file from a remote server with a known directory structure, what about downloading a file located in an unknown location, but with a known reference to the location via a download link. For example, How can you program a PHP script to submit a login form automatically, and then process to download a file whos location can only by the download link which looks something like : file.asp?file=xxxxunicodefilenamexxxxx.extention. I know how to form the PHP code to loginto the site automatically, but form there it gets a little problematic. The code then needs to click on a link, and then proceed to downlaod the file to a location without user intervention. 1). How do you tell PHP to 'click' on a link, and; 2). Save the download file. Thanks for your help in advance. Link to comment https://forums.phpfreaks.com/topic/109575-form-and-auto-file-download/ Share on other sites More sharing options...
jonsjava Posted June 10, 2008 Share Posted June 10, 2008 My best guess answer would be this: Curl. (so helpful, huh?) Well, I don't know curl, because I've never touched it before. I've helped people who've had syntax issues while using CURL, but that's about the limit of my knowledge on that subject. Maybe someone else would be willing to help this guy out? Link to comment https://forums.phpfreaks.com/topic/109575-form-and-auto-file-download/#findComment-562039 Share on other sites More sharing options...
ThunderAI Posted June 10, 2008 Author Share Posted June 10, 2008 My best guess answer would be this: Curl. (so helpful, huh?) Well, I don't know curl, because I've never touched it before. I've helped people who've had syntax issues while using CURL, but that's about the limit of my knowledge on that subject. Maybe someone else would be willing to help this guy out? I did a quick search for cURL in the PHP manual and it all looks very exiciting; however, I dont know the first thing about anything cURL. From what I can see it looks like if i could feed the cURL the link to the document it might be able to output the file to the screen, which is not ideal since i need the file to download to my server for processing. Link to comment https://forums.phpfreaks.com/topic/109575-form-and-auto-file-download/#findComment-562059 Share on other sites More sharing options...
DarkWater Posted June 10, 2008 Share Posted June 10, 2008 Wait wait. Download the physical file, like FTP, or the output of the file? If the latter, use file_get_contents(). Link to comment https://forums.phpfreaks.com/topic/109575-form-and-auto-file-download/#findComment-562061 Share on other sites More sharing options...
ThunderAI Posted June 10, 2008 Author Share Posted June 10, 2008 Wait wait. Download the physical file, like FTP, or the output of the file? If the latter, use file_get_contents(). The file can only be received by clicking on a link on the website like file.asp?file=nameofile. There is no way to know the actual location of the file on the server. So it is the file by association i suppose. I gave this code a try, and it tells me it can not find the function, even though i have turned it on in PHP.ini and restarted the webserver <? $url="---URL---"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); $store = curl_exec ($ch); $xml = curl_exec ($ch); curl_close ($ch); ?> Link to comment https://forums.phpfreaks.com/topic/109575-form-and-auto-file-download/#findComment-562065 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.