I tried several ways to do something like "php file reads the file in url, writes another file within ftp"
Code tested 1:
<!-- language: lang-php -->
<?php
if(empty( $_POST['q']))
exit('Use o parametro q');
$url = 'https://www.youtube.com/watch?v=' . $_POST['q'];
$ch = curl_init();
$Variaveis = array(
'format' => 'json',
'video' => $url
);
$url = 'http://youtubeinmp3.com/fetch/?' . http_build_query($Variaveis);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
curl_close($ch);
$dados = json_decode($response, true);
$src = fopen($dados['link'], 'r');
$dest = fopen($_POST['f'] . '.mp3', 'w');
stream_copy_to_stream($src, $dest);
?>
In FTP it copies files with .txt extension .png (Direct Files), when it is the one of the URL that I need, it creates the file, but does not write, and stays with 0kbs.
Now when I testo in localhost here at home it works normal.