/    Sign up×
Community /Pin to ProfileBookmark

how to view an image to the upload directory?

how to view an image to the upload directory?

i am using this <img src=$row[image]> correct me if im wrong here…

below is my php code for my upload.php but the problem is how to view the image?

hope anyone can help me..

[code=php]
<?php
if (array_key_exists(‘_submit_check’, $_POST)){

$max_image_width= 380;
$max_image_height= 600;
$max_image_size= 64 * 1024;
$image_type = array(“gif”,”jpg”, “jpeg”);

if (isset($_FILES[“userfile”])) {

if (is_uploaded_file($_FILES[“userfile”][“tmp_name”])) {

$image_name = $_FILES[“userfile”][“tmp_name”];
$ext = substr($_FILES[“userfile”][“name”],
1 + strrpos($_FILES[“userfile”][“name”], “.”));

if (filesize($image_name) > $max_image_size) {

$error = “Error: File size > 64K.”;

} elseif (!in_array($ext, $image_type)) {

$error = “Error: Invalid file type.”;

} else {

$image_size = GetImageSize($image_name);

if (($image_size) && ($image_size[0] < $max_image_width) && ($image_size[1] < $max_image_height)) {

$uploaddir = “/home/simply22/public_html/admin/cj/”;

if (move_uploaded_file($_FILES[“userfile”][“tmp_name”], $uploaddir .
$_FILES[“userfile”][“name”]))
{
$msg = “The file has been uploaded, and your information has been added to the directory”;
} else {
$error = “Error: moving fie failed.”;
}
} else {
$error = “Error: invalid image properties.”;
}
}
} else {
$error = “Error: empty file.”;
}

$couponstore=$_POST[‘couponstore’];
$coupontitle=$_POST[‘coupontitle’];
$website=$_POST[‘website’];
$userfile=$_FILES[‘image’];
$image_name=$_POST[‘image_name’];
$image_type=$_POST[‘image_type’];
$image_size=$_POST[‘image_size’];
$detail=$_POST[‘detail’];
$days=$_POST[“days”];
$date=$_POST[‘date’];
$feat=$_POST[‘feat’];
$sto_cat=$_POST[‘sto_cat’];

$sql=”INSERT INTO deals (couponstore, coupontitle, image, image_name, image_type, image_size, website, detail, days, date, feat, sto_cat) values(‘$couponstore’, ‘$coupontitle’, ‘$userfile’, ‘$image_name’, ‘$image_type’, ‘$image_size’,’$website’, ‘$detail’, ‘$days’, ‘$date’, ‘$feat’, ‘$sto_cat’)”;
$result=mysql_query($sql,$dbh) or die(mysql_error());
}
}
?>
[/code]

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@tcaNov 11.2007 — Try:

<img src="<?php echo 'pathtoimage/' . $row['image']; ?>" />

You don't need 'pathtoimage/' . if the image and the PHP file are in the same folder.

TC
Copy linkTweet thisAlerts:
@lyndonauthorNov 11.2007 — ok thanks for the response

i try to this <img src="<?php echo 'pathtoimage/' . $row['image']; ?>" />

but no image. The image and the php file is not on the same folder.

this is where i put the images:

/home/simply22/public_html/admin/cj/
Copy linkTweet thisAlerts:
@tcaNov 11.2007 — Assuming the file that calls the image is in admin

<img src="<?php echo 'cj/' . $row['image']; ?>" />

File Paths

TC
×

Success!

Help @lyndon spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...