Display Image to Browser Directly from PC source using PHP -


how file source path users pc when submit file on form below.

<form action="" method="post" enctype="multipart/form-data">     <input type="file" name="image">      <input type="submit" name="submit" value="submit"> </form> 

example path want file:///c:/users/hafizul/downloads/myimage.png

so, can display user image using code below:

<?php $path = 'file:///c:/users/hafizul/downloads/myimage.png'; header('content-type:image/png'); echo file_get_contents($path,file_use_include_path); ?> 

thanks!

you not know file came on computer reliably, can send uploaded file browser seemed attempting:

header("content-type: image/png"); readfile($_files['file']['tmp_name']); 

refer php manual chapter "handling file uploads":

http://php.net/manual/en/features.file-upload.php


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -