2016-11-27 46 views
-1

我正在處理個人資料圖片上傳。 我已經治好了,所以你可以上傳一個文件到我的服務器,它會得到一個隨機的名字。無法更新我的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數據庫。

THE CODE

enter image description here 如果有人知道什麼即時做錯了PLSS幫助我。

UPDATE

所以我的問題是,我不能更新我的MySQL tbale。 Everythinbg其他工作正常。它只是當我嘗試更改我的mysql表中的['profile']選項卡時它開始工作。我嘗試用$file_path更改我的['profile']

+0

這將是很好,你更新你的文章更多的細節。你會得到什麼錯誤?你究竟想達到什麼目的? – nyedidikeke

+0

我現在更新了它,閱讀底部的文字:D –

+1

什麼是錯誤? – Tiger

回答

-1

你的動作是空白的。你可能想先填充它。

-1

如果動作默認爲空將發送POST請求到同一頁上,這樣就不會影響數據庫插入。

檢查您的數據庫結構配置文件的列是varchar或什麼?

+0

這是我的表格。 https://gyazo.com/dcfd9e22de0d7b3c2ca37d3a245b3071 –

+0

@RobinFors:你是否介意以上述評論更新你的文章? – nyedidikeke

+0

確保您的$ file_path不會增加50個字符,或者將配置文件增加到varchar 255 –