我尝试将单个文件上传到我的ftp目录但无法上传文件。我一直收到以下错误
警告:ftp_put()期望参数3是有效路径,给定数组
<form action="" class="tsc_form_contact_light frame tbar" method='post' enctype="multipart/form-data">
<label for="name">ArtWork Name <font color='red'>(required)</font></label>
<input type="upload" name="artname" class="form-input" required />
<label for="name">ArtWork Image</label>
<input type="file" id="uploadfile" name="uploadfile">
</form>
$path_of_storage = '/public_html/newinvoice/orderimage/';
$newftpdir = $_SESSION['SESS_ORDER_ID'];
$conn_id = ftp_connect($ftpserver);
ftp_pasv($conn_id, true);
$login_result = ftp_login($conn_id, $ftplogin, $ftppass);
//ftp_mksubdirs($conn_id,$path_of_storage,$newftpdir);
$source_file = $_FILES['uploadfile']['tmp_name'];
$destination_file = "$path_of_storage".$source_file;
$destination = "$path_of_storage";
// check connection
if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has failed!";
exit;
} else {
echo "Connected";
}
// upload the file
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
$name = $_FILES["uploadfile"]["name"];
move_uploaded_file($source_file, "$destination/$name");
// check upload status
if (!$upload) {
echo "FTP upload has failed! $destination_file";
} else {
echo "Uploaded $source_file as $destination_file";
}
// close the FTP stream
ftp_close($conn_id);
答案 0 :(得分:1)
$ _ FILES包含所有上传文件的数组以及name,type,tmp_path等属性
使用$ _FILES ['uploadfile'] ['tmp_name']作为文件路径
有关详细信息,请参阅此link