Sunday, 15 September 2013

php - cURL save file and rename? -


I am downloading the file and saving a file from another server on my server, except that I The file I am downloading has access token

  http://www.example.com/video.mp4?versionId=c_.Qeh.dz.zqPA3zc57HFDKEAmKG3xr2   

Loading the following one Results in the permission error:

  http://www.example.com/video.mp4   

The problem is, when I curl with the following code: $ url = 'http://www.example.com/video.mp4?versionId=c_.Qeh.dz.zqPA3zc57HFDKEAmKG3xr2'; $ FH = FOPAN ($ url, "wb"); $ Ch = curl_init ($ url); Curl_setopt ($ CH, CURLOPT_FILE, $ FH); Curl_exec ($ ch); Curl_close ($ ch);

File is saved as video.mp4? VersionID = CI.Q.AJGA.PA. 3. JC 57 HFDKAAMKG3XR2 (with token) and no video.MP4, which means that I can not do anything with it later, this one. MP4 is not

What's the solution here? I tried

  rename (video.mp4? VersionId = c_.Qeh.dz.zqPA3zc57HFDKEAmKG3xr2, video.mp4)   

but for this the file name And access is required token to stop it.

instead of using parse_url Basename Or combine them. Take the path from parse_url (without parameters) and then use the basename function.



No comments:

Post a Comment