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":
Comments
Post a Comment