2014-10-31 37 views
-2

我寫了下面的代碼,但沒有得到現在我想顯示圖像,而不是輸入類型=「文件」

<div class="image-upload" style="position: absolute; margin-top: -39px; margin-left: 376px;"> 
    <label for="file-input"> 
     <img width="50%" height="50%" src="images/camera-icon.png"> 
    </label> 
    <input type="file" id="prod_pic" name="imgfile" style="display:none;"> 
</div> 
+0

ç你還應該添加你的PHP代碼嗎? – 2014-10-31 10:53:15

+0

你需要設計幫助或php代碼幫助嗎? – 2014-10-31 10:54:24

+0

其實在Jquery中,我沒有獲得文件字段$(document).on('change','#prod_pic',function()的值$('#prod_pic').val()); \t}); – 2014-10-31 10:55:45

回答

1

我創建了一個自定義的文件輸入文件字段的值,這裏是代碼:

<span class="customInputFile"> 
    <div id="fileUpdate"> 
     <div id="fileUpdate-left"> 
      Anexe o seu currículo 
     </div> 
     <div id="fileName"></div> 
    </div> 
    <input type="file"> 
</span> 


$('#fileUpdate').on("click", function() { 
    $(this).next('input[type="file"]').click(); 
    $(this).next('input[type="file"]').change(function(){ 
     fileName = $(this).val().replace(/C:\\fakepath\\/i, '') 
     $('#fileName').text(fileName).animate({ 
      marginTop: '13px' 
     }); 
    }); 
}); 


.customInputFile{ 
    display: block; 
    margin: 0 0 10px 0; 
    cursor: pointer; 
} 
.customInputFile input[type="file"] { 
    display: none; 
} 
.customInputFile #fileUpdate { 
    background: rgb(114,191,68); 
    display: block; 
    padding: 25px 0; 
    color: rgb(255,255,255); 
    text-align: center; 
    overflow: auto; 
} 
.customInputFile #fileUpdate #fileUpdate-left{ 
    display: inline-block; 
    width: 190px; 
    font-size: 20px; 
    line-height: 23px; 
    font-family: 'museo_sans500'; 
    text-transform: uppercase; 
    text-align: left; 
} 

這裏是一個小提琴:http://jsfiddle.net/srp3827v/

把我的代碼作爲例子,在你途中的風格化......

相關問題