我正在處理個人資料圖片上傳。 我已經治好了,所以你可以上傳一個文件到我的服務器,它會得到一個隨機的名字。無法更新我的mysql表
我現在的問題是,我不能更新我的MySQL表,所以它有一個個人資料圖片。
這是我的代碼,用於檢查文件是否正常。
<div class="profile">
<?php
if (isset($_FILES['profile']) === true) {
if (empty($_FILES['profile']['name']) === true) {
echo "Please chose a file";
} else {
$allowed = array('jpg', 'jpeg', 'gif', 'png');
$file_name = $_FILES['profile']['name'];
$file_extn = strtolower(end(explode('.', $file_name)));
$file_temp = $_FILES['profile']['tmp_name'];
if (in_array($file_extn, $allowed) === true) {
change_profile_image($user_id, $file_temp, $file_extn);
} else {
echo 'Incorrect file type. Allowed - ';
echo implode(', ', $allowed);
}
}
}
if (empty($user_data['profile']) === false) {
echo '<img src="', $user_data['profile'],'" alt="',$user_data['userName'],'s Profilepicture">';
}
?>
<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="profile"><input type="submit">
</form>
</div>
然後我othercode PHP腳本wher我給它一個隨機名稱和要上傳到mysql數據庫。
UPDATE
所以我的問題是,我不能更新我的MySQL tbale。 Everythinbg其他工作正常。它只是當我嘗試更改我的mysql表中的['profile']
選項卡時它開始工作。我嘗試用$file_path
更改我的['profile']
。
這將是很好,你更新你的文章更多的細節。你會得到什麼錯誤?你究竟想達到什麼目的? – nyedidikeke
我現在更新了它,閱讀底部的文字:D –
什麼是錯誤? – Tiger