[轉]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

jquery live bind在click

確實搞錯使用方式 正確來說,用id時,如果要多個相同,可能只會綁定第一個 所以最好用 class或是html元素(p href…)之類才能綁住 另外綁住之後,取值要記得用$(this),這樣才會取到 執行綁定的元件 重要:live新版停用,請用on ….這是試了很久才發現,為什麼javascriprt一直錯,才發現沒live這function,才知道新版刪除function,請用on 或bind ========================= element.click 如果有新增或變更element會失敗 $("#pic_del").click bind比較沒什麼問題,但也有可能 $("#pic_del").bind(‘click’, function() { http://stackoverflow.com/questions/7268580/bind-click-and-live-click live是最好,但不能直接 #pic_del是a href,所以 $("#pic_del").live(‘click’, function() { 會失敗 按連結說明,要找到對應的selector再指定 也許 $("#xxx a").live(‘click’, function() { 但實際上…用bind比較快,live會失效…..也許是我搞錯或用錯方式 DOM traversal methods are not supported for finding elements to send to .live(). Rather, the .live() method should always be called directly after a selector

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