Posts

jquery - Save base64 encoded image into the file in PHP -

i have following code : <?php header('content-type: image/png'); $data = "ivborw0kggoaaaansuheugaaauaaaai8cayaaacwih5daaagaelkzjgrcxxoauipzztlg......"; define('upload_dir', '/home/desktop/image.png'); $img = $data; $img = str_replace('data:image/png;base64,', '', $img); $img = str_replace(' ', '+', $img); $data = base64_decode($img); $file = upload_dir . uniqid() . '.png'; $success = file_put_contents($file, $data); print $success ? $file : 'unable save file.'; ?> here $data contain encoded string of image in base-64. want save image file. did previous code go through lot of tutorial in google it's not working. can me going wrong. thanks in advance. define('upload_dir', '/home/xpointers/desktop/'); remember! apache webserver run own user rights (e. g. www-data). take care, apache user or group apache runs in have access desired directory. test can c...

jdbc - SQLite exception on Windows and not Mac OSX -

i'm developing mac os x java application uses sqlite database using jdbc driver. the code works fine on mac, can't use batch inserts using preparedstatement s on windows box. edit: doesn't work simple statement s contains single insert into instructions ( create table works fine). my code basically: table creation: final string sql = "create virtual table " + table_name + " using fts3(" + key_nom + ", " + key_prenom + ", " + key_adresse + ", " + key_adresse2 + ", " + key_adresse3 + ");"; try { final statement s = mconnection.createstatement(); s.execute(sql); } catch (final sqlexception e) { l.e("unable create table: "+sql+"! "+e); } preparedstatement creation: string sql = "insert "+table_name +" (" ...

primefaces - How to apply DataTable filter programatically? -

using primefaces demo filtering datatable ( http://www.primefaces.org/showcase/ui/datatablefiltering.jsf ) example, able provide "filtering" links outside of table user click (say volvo, forw, bmw, etc). when user clicks link, switch selected item in manufacturer filter dropdown , apply filter. haven't been able figure out how filter properties make change. can done via javescript? how access selection list , set current selection? update: following daniel's link, managed dropdown selection change, unable filter apply. in columns filters based on input field, triggering keyup causes data filter can't figure out event trigger on select make filter. here code using: <p:commandlink id="filterlink" value="click filter volvo only" onclick="$('#carform\\:datatable\\:manufacturercolumn_filter').val('volvo'), $('#carform\\:datatable\\:manufacturercolumn_filter').trigger('filter')"...

Jquery : Set Value for a Range in a Dictionary -

i want set values range in jquery dictionary object somthing this var temp_dict = {'1-10': 'woolen', '11-25':'light woolen', '26-36':'light cotton'} here keys 1-10, 11-25, 26-36 different ranges of temprature. want store in dictionary , call them : alert(temp_dict[15]); so checks in range , returns appropriate result. is there way achieve this?? function gettemp(t) { (var key in temp_dict) { var range = key.split("-"); if (t >= range[0] && t <= range[1]) return temp_dict[key]; } } var temp = gettemp(15); demo: http://jsfiddle.net/wpxdx/

php - Run parallel handler of curl with curl_multi_exec -

why in piece of code need call 2 times curl_multi_exec function. on first loop i'm executing curl_multi_exec handler run sub handler. when curlm_call_multi_perform different $mrc loop ends. in second loop, find results curl handlers, , first loop executed again, why? <?php { $mrc = curl_multi_exec($multihandle, $active); } while ($mrc == curlm_call_multi_perform); while ($active && $mrc == curlm_ok) { if (curl_multi_select($multihandle, $timeout) != -1) { { $mrc = curl_multi_exec($multihandle, $active); } while ($mrc == curlm_call_multi_perform); } } ?> the code extracted php-doc site the answers here curl_multi_exec() . it's frustrating php's documentation can useless in aspects ...

javascript - multiple countdowns on same page with jquery -

i'm having little problem jquery/javascript countdown , i'm hoping can me. so, have timer function, has 1 parameter, called selector (jquery selector) .. function timer(selector) { self = $(selector); var sec = parseint(self.find('span.timeout').text()); var interval = setinterval(function() { sec--; if (sec >= 0) { self.find('span.timeout').text(sec); } else { setinterval(interval); } }, 1000); } in, html have this. <div class="element" id="el1"><span class="timeout">10</span></div> <div class="element" id="el2"><span class="timeout">10</span></div> multiple elements same class , different id's and usage of function this: $("body").on('click', '.element', function() { timer(this); }); on first click works fine, timer counts down. when click on secon...

java - JAXB wrap wrapped collections -

i have class contain 2 lists. want generate wrapper element around list elements, , around 2 list. class someclass { private list<typea> lista; private list<typeb> listb; } <some-class> <lists> <list-a> <element-from-list-a /> <element-from-list-a /> <element-from-list-a /> ... </list-a> <list-b> <element-from-list-b /> <element-from-list-b /> <element-from-list-b /> ... </list-b> </lists> </some-class> i can generate wrapper around list xml-element-wrapper can't wrap 2 list 1 element. is possible in jaxb and/or in moxy implementation? after asked question solved problem moxy's xml-path extension, i'm still interested in standard jaxb solution problem.