0

I want insert the value for original image and cropped image ,i had done for cropped image.original image i had pass the src value in ajax,next page i am getting that value and inserting that value,but don't know how to move the image in one folder

   <div class="img-container">
      <img src="img/cropped-images/picture.jpg" alt="Picture">
    </div>
    <script>
        var original_image = $('img').prop('src');  
         $.ajax({
                        type:'POST',
                        url: "new_crop_image.php",
                        data: ({
                            'crop': result.toDataURL(),//this value i got and working fine
                            'image_var': original_image//this one not working,

                            }),
              }); 
     </script>

define('UPLOAD_DIR', 'img/cropped-images/');
$img = $_REQUEST['crop'];
$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);
$result=$success ? $file : 'Unable to save the file.';
$explode=explode("/",$result);
$count=count($explode);
//echo $count.'<br>';
for( $i = 0; $i < $count; $i++ )
 {
if($i==2){
  $filename = $explode[2];  
 }
 }

include('dbconfig.php');
$ssmid='SSM_offline128';
$status='0';
$approve='NO';
$reg_date=date('Y-m-d H:i:s');
$image = $_REQUEST['image_var'];//http://192.168.9.5/new/KANI/image-    cropper/img/cropped-images/picture.jpg  
$explode=explode("/",$image);/*  Array
                        (
                            [0] => http:
                            [1] => 
                            [2] => 192.168.9.5
                            [3] => new
                            [4] => KANI
                            [5] => image-cropper
                            [6] => img
                            [7] => cropped-images
                            [8] => picture.jpg
                        ) */

$original_image=$explode[8];// picture.jpg
$sql=mysql_query("INSERT INTO user_timeline_photos(ssmid,image,original_image,status,date_uploaded,timelinephoto_approved) VALUES('$ssmid','$filename','$original_image','$status',' $reg_date','$approve')");
CarlosCarucce
  • 3,420
  • 1
  • 28
  • 51
Raja R
  • 21
  • 6
  • Are you looking for [rename](http://php.net/manual/en/function.rename.php)? It also moves files between folders. Or do you just want to write it to disk? – syck Nov 24 '15 at 12:04
  • i want to move the image in one folder ,rename process next – Raja R Nov 24 '15 at 12:05
  • Moving is between different filesystem locations, storing or writing is from memory to disk, transferring is from client to server. – syck Nov 24 '15 at 12:07
  • Related: http://stackoverflow.com/questions/2320069/jquery-ajax-file-upload – Florian Müller Nov 24 '15 at 12:07

0 Answers0