views:

110

answers:

4

there is a page that i need to post a password to it and then i get a file to download. the post goes to the same page address its loads again and pop up the download manager (download starts automatically). now i want to do the same but in curl, i posted the data to the url and then its sends me the file back but i don't want my script to download the whole file i want only to get a link to download it by myself. how can i do that?

A: 

Actually, you most probably can't. Such password protected download system usually checks either cookies or browser / environment based variables. Getting the link itself shouldn't be problem, however you could not use it outside this generator's scope anyway.

Mikulas Dite
i got the headers without the body, there i see only the content size, no file name or link, if the content size is like the file size then i assume the password is right. now i dont want to give the person the password only the link, so how can i do that i dont want my curl server to download all the file and send it to the person.maybe i will send a hidden form with the correct password to the person and then it will automatically post it to the right server and get the file, but there is a chance that the user can see the password if he have firebug. there is another way you recommend?
Ben
here is what i get (with a curl limit of 3 sec if it was without limit it will download the all file):http://pagesalike.com/picspile/images/2.jpg
Ben
A: 

firstly you need to post that password with curl assuming "on specific form. the form will take you to the downloading page" now you need to use regex (regular expressions). filter the data you want then save it on other variable to re-use it.

ermac2014
but the received data is the whole file i don't want to download it with curl, i want to grab only the link to it and send it to the user to download.
Ben
A: 

There is for sure a redirection after you hit 1st page with POST. Look for that redirection with curl and read http response headers: Content-Location or Location or even Refresh

f13o
A: 

To prevent the automatic download you have to set the curl opt to not follow redirects. I can't remember the exact command but curl by default will follow auto refreshes and URL redirects, which happen in split seconds so humans don't actually see it happening.

I kinda don't understand what you really want to do, but if you just want a link then have the php script perform the entire curl post and everything when they click it. Doesn't matter what the web server will require a password before access to a file, you can't skip that step.

Michael Ozeryansky