2017-04-24 65 views
-1

如果用戶從輸入type = file上傳圖像,則需要處理,然後傳遞路徑,否則傳遞img src路徑。如果用戶從輸入type = file上傳圖像,則傳遞路徑,否則傳遞img src路徑。

怎麼樣?

<div class="thumb thumb-rounded thumb-slide"> 
    <img src="<?php echo $result['staff_signature'];?>" alt="Signature IS BLANK"> 

    <div class="caption"> 
    <input type="file" class="file-input" data-show-caption="false" data- show-upload="false" accept="image/*" id="signature" name="signature"> 
    </div> 
</div> 
+0

您能更具體地瞭解您的要求嗎? –

+0

請分享相關代碼並更好地解釋您的問題 – vlk

+0

如果你想知道如何使用PHP上傳文件,請檢查此參考資料 - https://www.w3schools.com/php/php_file_upload.asp – mi6crazyheart

回答

0

據我從烏爾問題理解我覺得你需要這個..

<div class="thumb thumb-rounded thumb-slide"> 
     <img src="<?php echo $result['staff_signature'];?>" alt="Signature IS BLANK"> 

     <div class="caption"> 
     <input type="file" class="file-input" data-show-caption="false" data- show-upload="false" accept="image/*" id="signature" name="signature"> 
     </div> 
    </div> 
    <input type="hidden" name="imgsrc" id="imgsrc" value="<?php echo $result['staff_signature'];?>"> 

上傳部分

if($_FILES[signature]['name']!="") 
     { 
    //file upload code 
     } 
    else 
    { 
    $imgsrc=$_POST['imgsrc']; 
//get the imgsrc value using GET/POST ..whatever u are using the form 

    } 

讓我知道您的反饋

+0

非常感謝。 –

+0

我歡迎.. :-) – Vimal

1

您可以將用戶的文件上傳到從字段的表單與AJAX的服務器,但如果你想對我好給用戶,並顯示預覽,您需要做的往返並上傳文件到服務器第一

+0

這實際上是配置文件圖片更新的代碼。第一次秋天,我在中顯示圖像如果用戶不使用替換圖像,並且使用然後傳遞上傳圖像的路徑,我想傳遞相同的路徑。 –