PHP를 사용하여 선택한 로컬 파일을 FTP로 업로드하고 싶습니다.PHP를 사용하여 선택한 파일을 FTP로 업로드
<form method="POST" ENCTYPE="multipart/form-data">
<input type="file" name="filename"/><br/>
<input type="submit" value="Upload"/>
</form>
그리고이 업로드 시도 :
$source_file=$_FILES['filename']['tmp_name'];
$remote_file='/www/img/file.txt';
if (ftp_put($conn_id, $remote_file, $source_file, FTP_BINARY))
{
echo "successfully uploaded $source_file\n";
}
else
{
echo "There was a problem while uploading $source_file\n";
}
결과 :
경고 : ftp_put() :
로컬 파일은
$_POST
방법을 사용하여 선택 파일 이름은 비워 둘 수 없습니다
$_FILES['filename']['tmp_name']
이 비어 있습니다.
나는 $source_file
이 경로 여야한다는 것을 알고 있습니다. 그래서 질문이 있습니다 : 선택한 파일의 올바른 경로는 무엇입니까?
시도 지역에 업로드 된 파일을 먼저 이동 한 다음 ftp로 이동하십시오 .https : //secure.php.net/manual/en/function.move-uploaded-file.php –
[파일 업로드 가능 FTP 및 PHP를 사용하여] (http://stackoverflow.com/questions/34465646/upload-a-file-using-ftp-and-php) –