php - Show images from temp directory to end users -


i doing image rotate functionality. rotating image , saving tmp directory using

$rotate = imagerotate($source, 90, 0); $rotatedtmpfile = tempnam('/tmp', 'rotatedthumbnailimage'); imagejpeg($rotate, $rotatedtmpfile ,100); 

files created in tmp folder. want

  1. read content of tmp directory
  2. generate url of tmp image file
  3. send src response ajax call

javascript:

$.ajax({     url: padmin.roateimageurl,     data: {         mediaid: id[1],         src: src     },     type: 'post',     success: function(response) {         img.attr('src', response);     } }); 
  1. show rotated image end user before uploading on s3 server.

please help.

i'm pretty sure /tmp not accessible via webserver directly. should either move /tmp directory in docroot, or alternatively encode image in html directly; using

$mime = mime_content_type($rotatedtmpfile); $data = file_get_contents($rotatedtmpfile); exit('data:' . $mime . ';base64,' . base64_encode($data)); 

this should work image-src might resource-expensive


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -