php - تحميل ملف باستخدام فتب و فب
html upload (2)
استخدم $_FILES["file"]["tmp_name"]
بدلا من $_POST["file"]
تصحيح:
$file = $_FILES["file"]["tmp_name"];
$file_name = $_FILES["file"]["name"];
// upload file
if (ftp_put($ftp_conn, $file_name, $file, FTP_BINARY))
أو نقل الملف الذي تم تحميله أولا:
$target_path = "uploads/".basename($_FILES["file"]["name"]);
move_uploaded_file($_FILES["file"]["tmp_name"], $target_path);
لا أستطيع تحميل الملف باستخدام فب لأنني لا يمكن إرسال المسار حصلت من ملف هتمل إلى وظيفة FTP_PUT لأنه يأخذ فقط سلسلة "test.txt"
كيف يمكنني إرسال المسار إلى هذه الوظيفة
ملف فب
$file = $_POST["file"];
// upload file
if (ftp_put($ftp_conn, $file, $file, FTP_BINARY))
{
echo "Successfully uploaded $file.";
}
else
{
echo "Error uploading $file.";
}
// close connection
ftp_close($ftp_conn);
ملف هتمل
<div class="container">
<div class="row">
<div class="col-lg-12">
<form class="well" action="Upload.php" method="post" >
<div class="form-group">
<label for="file">Select a file to upload</label>
<input type="file" name="file" id="file">
<!-- <p class="help-block">Only jpg,jpeg,png and gif file with maximum size of 1 MB is allowed.</p> -->
</div>
<input type="submit" class="btn btn-lg btn-primary" value="Upload">
</form>
</div>
</div>
</div>
تحقق من أن المسار صحيح ... لا أعرف بنية الملف الخاص بك لذلك أنا التخمين كنت في حاجة إلى المسار الكامل، في محاولة ...
if (ftp_put($ftp_conn, getcwd().$file, $file, FTP_BINARY)