TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Advanced PHP Programming (http://www.talkphp.com/advanced-php-programming/)
-   -   cURL - m4v (http://www.talkphp.com/advanced-php-programming/4987-curl-m4v.html)

russellharrower 10-01-2009 10:50 AM

cURL - m4v
 
Hi i am using the following code to transfer files that start with m4v, however they are not copying over. i was wondering if cURL is able to copy these files?

PHP Code:

<?php
/**
* Initialize the cURL session
*/
$ch curl_init();
/**
* Set the URL of the page or file to download.
*/


$filename 'http://example.com/file.m4v';

$finfo explode('.',$filename);
$fileSuffix array_pop($finfo);

curl_setopt($chCURLOPT_URL$filename);
/**
* Create a new file
*/

$fp fopen('r.'.$fileSuffix'w');
/**
* Ask cURL to write the contents to a file
*/

curl_setopt($chCURLOPT_FILE$fp);
/**
* Execute the cURL session
*/

curl_exec ($ch);
/**
* Close cURL session and file
*/

curl_close ($ch);

fclose($fp);

print 
'<a href="r.'.$fileSuffix.'"/>';
?>


Salathe 10-01-2009 11:21 AM

A file is a file is a file for curl, it doesn't matter what type. I suggest adding in some error checking and reporting to see what's going wrong.

Offtopic: I'd also suggest using pathinfo($filename, PATHINFO_EXTENSION) to grab the file extension rather than the explode/array_pop combo that you use.

gamer13 10-01-2009 02:55 PM

Maybe you can try it with the CURLOPT_BINARYTRANSFER flag.

TheOnly92 10-05-2009 12:02 PM

I wonder if you can directly access http://example.com/file.m4v directly? Otherwise you might need to add cookies or referral or something.


All times are GMT. The time now is 01:38 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0