TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 10-01-2009, 10:50 AM   #1 (permalink)
The Contributor
 
russellharrower's Avatar
 
Join Date: Jul 2009
Posts: 80
Thanks: 13
russellharrower is on a distinguished road
Default 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.'"/>';
?>
russellharrower is offline  
Reply With Quote
Old 10-01-2009, 11:21 AM   #2 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

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.
Salathe is offline  
Reply With Quote
Old 10-01-2009, 02:55 PM   #3 (permalink)
The Wanderer
 
gamer13's Avatar
 
Join Date: Sep 2009
Posts: 15
Thanks: 4
gamer13 is on a distinguished road
Default

Maybe you can try it with the CURLOPT_BINARYTRANSFER flag.
gamer13 is offline  
Reply With Quote
Old 10-05-2009, 12:02 PM   #4 (permalink)
The Contributor
 
Join Date: Mar 2009
Posts: 49
Thanks: 0
TheOnly92 is on a distinguished road
Default

I wonder if you can directly access http://example.com/file.m4v directly? Otherwise you might need to add cookies or referral or something.
__________________
There are no noobs and pros in this world, only people who know how to use Google and those who don't.
TheOnly92 is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot use CURL? allworknoplay Absolute Beginners 19 03-21-2009 08:27 PM
yet another curl question.... Jenski General 8 07-01-2008 10:36 AM
Saving ALL the cookie data using cURL Wildhoney Advanced PHP Programming 1 06-12-2008 07:07 PM
A serious curl checkbox problem bedri Advanced PHP Programming 1 05-22-2008 04:25 PM
Need to get XML file using a curl alternative chimpo Absolute Beginners 1 05-12-2008 08:46 PM


All times are GMT. The time now is 08:51 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design