Using fine-uploader i need to be able to get the selected file's original width and height dimensions in pixels so that i can use them for later use on my page. Is there a way to do this either once the file is selected or on the on complete success callback?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Fine Uploader doesn't provide this type of data, but it's simple to determine the dimensions of an image yourself. First, convert the image file to an object URL (URL.createObjectURL(file)
) then use that URL as the src attribute of an img element. Finally, after the <img>
has completely rendered, check the width and height properties of the element. Fine Uploader does this internally when it is asked to validate an image file based on specific dimension limits. See the image validation code for an example.