I have uploaded an image to the folder:
/var/www/uploads/img.png
using the relative path
../uploads/img.png
I then load the image with the following code:
$img = copy('../uploads/9', '/tmp/profile_picture');
Which returns true
And my googling got me to this:
<img src="/tmp/profile_picture" alt="profile_picture" />
I have tried the above with and without .png ending. still not working.
I just need to get out 1 picture and display in an image tag, and i always know the exact path and filename of my image.
EDIT
After the first answer in this thread i have tried the following:
$image = '../uploads/9';
$info = getimagesize($image);
// output the image
header("Content-Disposition: filename={$image};");
header("Content-Type: {$info["mime"]}");
header('Content-Transfer-Encoding: binary');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT');
readfile($image);
And i call the script here:
<img src="profile_picture.php" alt="profile_picture" />
and i get 404.
I've tried various paths for the $image
Any help appreciated.
<img src="uploads/img.png"/>why do you need to copy it?<img src="/uploads/img.png" alt="profile_picture" />? If you start with/on a website, it means the web server root, not your local file system root.