2013-12-14 26 views
0

我的任務這些功能是:我們如何achive使圖像上載

步驟1a:用戶上傳

輸入圖像:圖像的原始尺寸(固定寬度可變的高度) - 它可以是任何尺寸的。

限制:

A.類型:JPG/BMP/PNG等

B. MAX DIMENSION

-example 1024x1024像素。

步驟1b:上傳後,系統檢查符合我們標準的標準。

標準:檢查max尺寸

如果是:

如果匹配標準要求用戶創建尺寸的縮略圖像(145×190)

如果否:

再次詢問用戶重新調整圖像的大小,直到它符合我們的標準

最終輸出:

2)145×190(檢索結果圖像)(縮略圖)

3)30%的縮略圖

4)爲剖面PIC,我們將根據哪個高度會有所不同定義固定寬度(寬度尚未決定)


這是我的任務。 在這些任務中,我能夠實現圖像上傳,檢查尺寸。但不是一步一個腳印。請幫我完成這個任務。我是jquery的新手,只有1個月的經驗,這個任務對我來說非常複雜。 希望你能理解我的問題。

我coading是(用於檢查漁政船): HTML:

<input type="file" id="file" /> 

的jQuery:

var _URL = window.URL || window.webkitURL; 

$("#file").change(function(e) { 
    var file, img; 


    if ((file = this.files[0])) { 
     img = new Image(); 
     img.onload = function() { 
      alert(this.width + " " + this.height); 
     }; 
     img.onerror = function() { 
      alert("not a valid file: " + file.type); 
     }; 
     img.src = _URL.createObjectURL(file); 


    } 

}); 

我coading是(上傳圖片): HTML:

jQuery的:

function readURL(input) { 
      if (input.files && input.files[0]) { 
       var reader = new FileReader(); 

       reader.onload = function (e) { 
        $('#blah') 
         .attr('src', e.target.result) 
         .width(thumbWidth) 
         .height(thumbHeight); 
       }; 

       reader.readAsDataURL(input.files[0]); 
      } 
     } 
+2

你能證明你到目前爲止所嘗試過的嗎? – KrishnaDhungana

+1

另外提及什麼是服務器語言 – mplungjan

+1

請查看編輯代碼 – sonalgoyal

回答

1

這是解決(不完全,但希望它可以幫助你一些地方)

HTML:

<p>image is set to 100x100 pixels!</p> 

<img id="draggable" src="http://jotform.org/demo/jquery-image-area-select-plugin/images/sweet-dogs.jpg" /> 

<div id="dim"></div> 

的jQuery:

var img  = document.getElementById('draggable'), 
    new_img = new Image(); 

new_img.onload = function() { 
    var img_width = this.width, 
     img_heigth = this.height; 

    document.getElementById('dim').innerHTML = 'Original dimensions are : ' + img_width + 'x' + img_heigth + ' pixels'; 
} 

new_img.src = img.src; 

CSS:

#draggable {height: 100px; width: 100px;} 
+1

不是正確的答案,但幫助某處...謝謝 – sonalgoyal

相關問題