내가 내 서버 나에게 원격 파일을 가져옵니다 여기에이 스크립트를 가지고 설정PHP 원격 파일 다운로드
문제는 그 파일의 이름을 변경하려는 경우, 내가 수동으로 FTP 서버에와 가지고있다 파일의 이름을 바꿉니다. 다운로드하기 전에 파일의 이름을 지정해야합니까?
<?php
if($_POST){
//get the url
$url = $_POST['url'];
//add time to the current filename
$name = basename($url);
list($txt, $ext) = explode(".", $name);
$name = $txt.time();
$name = $name.".".$ext;
//here is the actual code to get the file from the url and save it to the uploads folder
//get the file from the url using file_get_contents and put it into the folder using file_put_contents
$upload = file_put_contents("uploads/$name",file_get_contents($url));
//check success
if($upload) echo "Success: <a href='uploads/".$name."' target='_blank'>Check Uploaded</a>"; else "please check your folder permission";
}
?>
<html>
<head><title>File Upload from URL</title></head>
<body>
<h3>File Upload from URL</h3>
<form action="" method="post">
Your URL: <input type="text" name="url" />
</form>
</body>
</html>
아무도 도와 주실 수 있습니까?
수동으로 파일의 이름을 바꾸어야합니다. 문제가 있습니다. 어쨌든 업로드하기 전에 이름을 지정할 수 있습니까? 사전에
감사
여전히 PHP 파일을 편집해야합니다. 이름을 지정하십시오 –
당신은 Javascript의'FileAPI'와 비슷한 것을 할 수 있습니다 - 그러나 약간의 과잉이며 브라우저와 호환되지 않습니다. –