[轉]jQuery file upload maxNumberOfFiles options--無用

http://stackoverflow.com/questions/16723877/jquery-file-upload-maxnumberoffiles-and-getnumberoffiles-options I believe getNumberOfFiles was only added as an option to a recent version of jquery.fileupload-ui.js (8.2.1). As an alternative, you can set the option singleFileUploads to false, and in the add callback you can throw errors if more than one file is added. var maxFiles = 1; $('#fileupload').fileupload({ singleFileUploads: false, url: '/uploadUrl' }).bind('fileuploadadd', function (e, data) { var fileCount = data.files.length; if (fileCount > maxFiles) { alert("The max number of files is "+maxFiles); return false; } });

2014-08-18 · 1 min · 78 words · Me

[轉]jquery file upload 改檔名

https://github.com/blueimp/jQuery-File-Upload/issues/622 看連結最下面 Here is some updated code that works with the most recent version as of July 18, 2014. class CustomUploadHandler extends UploadHandler { /* Converts a filename into a randomized file name */ private function _generateRandomFileName($name) { $ext = pathinfo($name, PATHINFO_EXTENSION); return md5(uniqid(rand(), true)).'.'.$ext; } /* Overrides original functionality */ protected function trim_file_name($file_path, $name, $size, $type, $error, $index, $content_range) { $name = parent::trim_file_name($file_path, $name, $size, $type, $error, $index, $content_range); return $this->_generateRandomFileName($name); } } $upload_handler = new CustomUploadHandler();

2014-08-16 · 1 min · 78 words · Me

[轉]圖片超過設定寬高,自動比較縮放 css方法 高手

http://stackoverflow.com/questions/11757537/css-image-size-how-to-fill-not-stretch .container { width: 150px; height: 100px; background-image: url(“http://i.stack.imgur.com/2OrtT.jpg"); background-size: cover; background-repeat: no-repeat; background-position: 50% 50%; }​ http://stackoverflow.com/questions/9883289/set-background-image-css-to-the-featured-image-in-wordpress-using-jquery 這個做了我想做的事,也是高手 $(‘section img’).each( function(){ var src = this.src, h = $(this).height(), w = $(this).width(); $(this).closest(‘div’).css({ ‘min-width’ : w, ‘min-height’ : h, ‘background-image’ : ‘url(’ + src + ‘)’, ‘background-repeat’ : ’no-repeat’, ‘background-position’ : ‘50% 50%’ }); }).remove(); ======= ‘background-image’ : ‘url(’ + src + ‘)’, 記得在加上”" => ‘background-image’ : ‘url("’ + src + ‘")’, ...

2014-08-14 · 1 min · 72 words · Me

開發心得 php 後台

像最近弄php後台,jquery php css jtable database jqueryfileupload,整個用了一遍 結論 要有好用 快速的framework 真的用ror肯定沒錯,因為開發久了,pg才是真正花時間的,省不下,沒工具就是省不下時間 回頭看java真的是怪物,開發速度暴減 php用framework就像ror一樣,主機是不開放更新framework

2014-08-13 · 1 min · 12 words · Me

datatable row_id

基本上官方的fnGetData和fnGetPosition之類,fnGetPosition拿到是抓出幾筆中第幾筆id和真正的Row_ID不一樣。用fnGetData一直拿到Object,根本解不開,試了官方和網路上的方式,全都不行。 fnrender被拿掉了…..無法判斷Object 最快方式:直接用jquery $(’#datatable tbody’).on( ‘click’, ’tr’, function () { 這行會取得tr 底下直接用 row_id = $(this).attr(‘id’).split("_")[1]; $(this).attr(‘id’)會找到tr用的id,得到值:ROW_22 split("_")之後:ROW 22,取[1],就行得到id。

2014-08-13 · 1 min · 18 words · Me