javascript - want to change the path of the saving images folder... how to do this -


javascript function call html2 canvas element scrrenshot the target div

<script type="text/javascript"> function capture() {     $('#target').html2canvas({         onrendered: function (canvas) {             //set hidden field's value image data (base-64 string)             $('#img_val').val(canvas.todataurl("image/png"));             //submit form manually             document.getelementbyid("myform").submit();         }     }); } </script> 

php code

<?php      //get base-64 string data      $filtereddata=substr($_post['img_val'], strpos($_post['img_val'], ",")+1);     //decode string    $unencodeddata=base64_decode($filtereddata);    //echo $unencodeddata;    //save image      $date = date_create();     $timestamp= date_timestamp_get($date);     echo $timestamp;     $rand = mt_rand(100000,999999);     echo $rand;     $string = "cp-string";    echo $string;    $name = "$string.$timestamp.$rand.png";  //$name = "$string/$timestamp/$rand.png";  //$unencodeddata = "$string/$timestamp/$rand";    file_put_contents($name , $unencodeddata);   ?> 

dont know how give different folders path saving image

normally use copy function upload file folder. according code can like

$dir_to_save = "foldername" if (!is_dir($dir_to_save)) {   mkdir($dir_to_save); }  $path = $dir_to_save."/".$name; file_put_contents($path, $unencodeddata); 

note: use absolute_path not relative paths

for more information


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -