2013-02-02 28 views
0

如果未選擇圖像,如何使用舊圖像會如何?PHP如何在未選擇圖像的情況下使用舊圖像

其個人資料頁時,有人更新他的個人資料,但不選擇更新,然後舊形象應該仍有圖像..

它應該是這樣的if-else語句或會有一些其他辦法??

//check if file is selected. 
    if (empty($_FILES['profilepic'])) 
    { 
       //if file selected this code should run 

     $fileselected="file selected"; 
    } 
    else 
    { 
       //this executes if file not selected 
     $fileselected="No File Has Been Selected"; 
    } 

echo $fileselected; 

它應該如何編碼?

+1

'如果($ _ FILES [ 「profilepic」] [ 「錯誤」]){//如果沒有選擇文件}其他{//如果文件被選中}'。使用基於此條件的不同SQL語句(取決於您的要求)。 – Lion

+0

什麼是您的更新查詢? – 2013-02-02 13:19:33

+0

@Lion Thankyou .. –

回答

1

由於@Lion

if($_FILES["profilepic"]["error"]) 
{//if the file is not selected} 
else {//if the file is selected} 

差不多的作品對我來說.. :)

+0

不客氣。將答案標記爲可接受的答案(當系統允許時)。 – Lion

0

如果(空($ _ FILES [ '形象'] [ '名']))
{
$ image = $ row ['image'];
//從根文件夾上傳//
$ upload = $ _ SESSION ['KCFINDER'] ['uploadURL'] ='/images'.$image;
上傳腳本
}
其他
{
正常上傳腳本
}

相關問題