URLからファイルをダウンロードするスクリプトです。私が望むのは、ユーザーがリンクを張って、スクリプトがすべてのファイルをダウンロードする3つ以上の入力urlボックスがあるようなマルチリンクです。私はボタンを押したくないし、別のURLボックスが現れる。それは私が望んでいない、私はすでにそれを試みた。または複数のリンク。私たちは各ライン上のリンクを置くことができ、このような何か:このカールスクリプトのマルチリンクを作成するにはヘルプが必要
<?php
class Download {
const URL_MAX_LENGTH=2000;
// clean url
protected function cleanUrl($url){
if (isset($url)){
if (!empty($url)){
if(strlen($url)< self::URL_MAX_LENGTH){
return strip_tags($url);
}
}
}
}
//is url
protected function isUrl($url){
$url=$this->cleanUrl($url);
if (isset($url)){
if (filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED)){
return $url;
}
}
}
//return extension
protected function returnExtension($url){
if ($this->isUrl($url)){
$end = end(preg_split("/[.]+/", $url));
if (isset($end)){
return $end;
}
}
}
// file download
public function downloadFile($url){
if ($this->isUrl($url)){
$extension = $this->returnExtension($url);
if ($extension){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$return = curl_exec($ch);
curl_close($ch);
// directory where files should be downloaded
$destination = "uploads/file.$extension";
$file = fopen($destination, "w+");
fputs($file, $return);
if (fclose($file)) {
echo "Successfully Download The File";
}
}
}
}
}
$obj = new Download();
if (isset($_POST['url'])) { $url = $_POST['url'];}
?>
<form action="index.php" method="post">
<input type="text" name="url" maxlength="2000">
<input type="submit" value="Download" />
</form>
<?php if (isset($url)) { $obj->downloadFile($url); }?>
[explode](http://php.net/manual/en/function.explode.php)を試してみませんか?新しいライン – Rohit
でそれを壊してくださいあなたは私がnewbeの少しPHPのカール(: – Abdulmanan