Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Print Images with PHP print function

Please help me out. I have a form that collects picture from an upload field in a client form and the picture to be printed out on the user page. this work perfectly well on localhost and it looks like the below Ilamini Ayebatonye Thanks A lot

NAME:     Name Surname

EMAIL ADDRESS:     [email protected]

HOME ADDRESS:     123 Random Street, FakeTown

PHONE NUMBER:     012345678911

QUALIFICATION:     I.C.T Certificate

SECTOR:     CCNA

INTEREST:     please put in your interest

Please Print this slip, attached your C.V and photocopies of your credentials and come with it to the day of the seminar.

but the problem with is that when I uploaded the site and try registering the picture won't show again,

what i see is the below

ECO9JA-CREATING JOBS IN ICT
          Backgrounds_15670_zps11bc080d.png    

NAME:     Name Surname

EMAIL ADDRESS:     [email protected]

HOME ADDRESS:     123 Random Street, FakeTown

PHONE NUMBER:     012345678911

QUALIFICATION:     I.C.T Certificate

SECTOR:     CCNA

INTEREST:     please put in your interest

Please Print this slip, attached your C.V and photocopies of your credentials and come with it to the day of the seminar.

THANKS FOR REGISTERING

the script is below for the image variable the form upload and the print fxn are as follows:

VARIABLE

<?php
$file= "file.csv";
$name = $_POST['name'];
$email = $_POST['email'];
$address = $_POST['address'];
$phone = $_POST['phone'];
$qualification = $_POST['qualification'];
$sector = $_POST['sector'];
$interest = $_POST['interest'];
$image= $_POST['image'];
<input type="hidden" name="MAX_FILE_SIZE" value="500">
<P>
<br>
<input type="file" name="image" value="upload" >

PRINT THIS CODE ON USERPAGE

<?php print"<img src=\"$image\" width=\"100px\" height=\"100px\"\/>";?>
like image 421
dagogodboss Avatar asked Mar 25 '26 04:03

dagogodboss


1 Answers

Use this just copy and paste in your project.

$contents=  file_get_contents('http://localhost/elgg_social/data/36/641483447202.jpg');

$expires = 14 * 60*60*24;

header("Content-Type: image/jpeg");
header("Content-Length: " . strlen($contents));
header("Cache-Control: public", true);
header("Pragma: public", true);
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT', true);

echo $contents;
exit;
like image 169
Aklesh Singh Avatar answered Mar 26 '26 19:03

Aklesh Singh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!