only get a red cross
Moderator: General Moderators
only get a red cross
hi,
i'm trying to get a picture from the database. it's in a blobfile. seems ok. but when i read it from the db theres a red cross???
any ideas?
THX
i'm trying to get a picture from the database. it's in a blobfile. seems ok. but when i read it from the db theres a red cross???
any ideas?
THX
scripts...
request if x is set
...
echo ( "<img src=\"viewImg.php?product_id=" .
$product[id] . "\" width=\"" . $product[width] . "\" height=\"" . $product[height] ."\" alt=\"" . $product[name] . "\" align=\"left\">\n" );
...
viewImg.phpmod_edit: added
...
echo ( "<img src=\"viewImg.php?product_id=" .
$product[id] . "\" width=\"" . $product[width] . "\" height=\"" . $product[height] ."\" alt=\"" . $product[name] . "\" align=\"left\">\n" );
...
viewImg.php
Code: Select all
<?
require ("./common/config.inc.php");
print "test";
// test for product_id
if(!isset($product_id))
{
echo ( "<!-- No Product ID Found. -->\n " );
exit;
}
if ( ( $dbh = mysql_connect( $dbServer, $dbUser, $dbPassword )) > 0 )
{
$res = mysql_db_query($dbDatabase, "SELECT product_image FROM $productTable WHERE product_id = '$product_id'", $dbh );
if(mysql_num_rows($res) == 0)
{
echo ( "<!-- No Image Found For Product ID $product_id. -->\n " );
exit;
}
else
{
$row = mysql_fetch_array($res);
Header( "Pragma: no-cache" );
Header( "Content-type: image/$row[product_image_format]");
echo ( $row["product_image"] );
}
$dbh = mysql_close();
}
?>Code: Select all
tags[/size]
there is a problem when i call viewImg.php the script will not be called!!!
so there is no picture (area with red cross) in the request script:(
any idea? i think i couldn't download a file??? why! are there another parameters then "file_uploads = On". there is no picture in dir by using example scripts for uploading:(
well seems fileupload runs quit normal. but the above scripts example not??? the file is saved in a blob(look example), but read seems not working. above its the normal way to read a blob from a $result!
any ideas???
THXat least
Did you test the remaining script? Tryand do not call it via <img src="..."> but as html-page to check the (debug-)output.
destroys your script. You cannot send headers after you printed something and the string makes the images data invalid.print "test";
Did you test the remaining script? Try
Code: Select all
<?php
require ("./common/config.inc.php");
// test for product_id
if(!isset($product_id))
{
echo ( "<!-- No Product ID Found. -->\nNo Product ID Found." );
exit;
}
else if ( ( $dbh = mysql_connect( $dbServer, $dbUser, $dbPassword )) !== FALSE)
{
$res = mysql_db_query($dbDatabase, "SELECT product_image FROM $productTable WHERE product_id = '$product_id'", $dbh );
if(mysql_num_rows($res) == 0)
{
echo ( "<!-- No Image Found For Product ID $product_id. -->\nNo Image Found For Product ID $product_id." );
exit;
}
else
{
$row = mysql_fetch_array($res);
// Header( "Pragma: no-cache" );
// Header( "Content-type: image/$row[product_image_format]");
echo ( strlen($row["product_image"]) );
}
mysql_close($dbh);
}
else
{
echo mysql_error();
}
?>still not working
still not working:( is there a problem with <img src...???
i've tried to save the img in a directory, but there might be no permission to add a file via the client browser...
THX for LISTENING;)
i've tried to save the img in a directory, but there might be no permission to add a file via the client browser...
THX for LISTENING;)
Just call the script as the img-tag would do, but call it yourself from the nav-bar of your browser.and do not call it via <img src="..."> but as html-page to check the (debug-)output.
This way you can see the error output of the script (if there is any).
Note: my changes on your script will not display the image data anymore but the data length
it's only for debuging// Header( "Pragma: no-cache" );
// Header( "Content-type: image/$row[product_image_format]");
echo ( strlen($row["product_image"]) );
Are you escaping slashes, if you are retrieving the file contents from the database and they contain slashes, this would corrupt the image and it will not display. you may or may not need this depending on how your server is configured.
try
try
Code: Select all
echo stripslashes($rowї"product_image"]);testing,testing,testing...
... nothing...
next test results in...
<?
mysql_connect("localhost","root","");
mysql_select_db("couponing");
$zeiger=mysql_query("select product_image from products where product_id = 100");
$res=mysql_fetch_array($zeiger);
Header( "Pragma: no-cache" );
Header( "Content-type: image/jpg");
echo ( $res["product_image"] );
?>
an example results in a pop up for download the script???
sorry for this confusion... but i test everything for working...damn:(
THX for your pleasure:)
yeah i found the error!!!
was in the insert of the data:(
sorry ... big program no eyes!
if ( $valid_image ) $productInfo["product_image"] = addslashes(fread(fopen($product_image, "r
"), filesize($product_image)));
[/b]
next test results in...
<?
mysql_connect("localhost","root","");
mysql_select_db("couponing");
$zeiger=mysql_query("select product_image from products where product_id = 100");
$res=mysql_fetch_array($zeiger);
Header( "Pragma: no-cache" );
Header( "Content-type: image/jpg");
echo ( $res["product_image"] );
?>
an example results in a pop up for download the script???
sorry for this confusion... but i test everything for working...damn:(
THX for your pleasure:)
yeah i found the error!!!
was in the insert of the data:(
sorry ... big program no eyes!
if ( $valid_image ) $productInfo["product_image"] = addslashes(fread(fopen($product_image, "r
[/b]
Last edited by devmatch on Thu Jun 12, 2003 9:44 am, edited 1 time in total.
sorry for ymy problems:(
alternative i tried to upload the file in the webservers dir:
failed to create stream: Permission denied in c:\web\root\couponingenv\admin\addcoupon.php on line 28

failed to create stream: Permission denied in c:\web\root\couponingenv\admin\addcoupon.php on line 28
Code: Select all
if ( $valid_image )
$productInfoї"product_image"] = addslashes(fread(fopen($product_image, "r"), filesize($product_image)));
}Code: Select all
echo ($rowї"product_image"]);Code: Select all
echo stripslashes($rowї"product_image"]);using windoof
it is possible to change the user rights from r to rw???
Re: using windoof
devmatch wrote:it is possible to change the user rights from r to rw in windows???
find my solution script:)
Code: Select all
<?php
if ($img1_name == "") {
?>
<html>
<head>
<title>Upload a File</title>
</head>
<!--
Formular: in einem Filepanel kann der Name
des lokalen Files angegeben werden,
das auf den Server hochgeladen werden soll.
-->
<body>
<h1>Upload a File</h1>
<form enctype="multipart/form-data" method="post"
action="<?php echo $PHP_SELF?>">
<p><strong>File to Upload:</strong><br>
<input type="file" name="img1" size="30"></p>
<P><input type="submit" name="submit"
value="Upload File"></p>
</form>
<?php
}
else {
$curdir=getcwd();
exec("/usr/local/info-sys/cgi-bin/phptouch
$SCRIPT_FILENAME $curdir/tmp/$img1_name",$t,$status);
if ($status > 2) { die ("<br>$t[0]"); }
if ($status == 2) {
print("File already exists, will be overwritten");
}
move_uploaded_file("$img1", "./tmp/$img1_name");
exec("phpchown $SCRIPT_FILENAME
$curdir/tmp/$img1_name",$r,$status);
if ($status >1) {
print("<br>$r[0]");
}
?>
<html>
<head>
<title>File Upload!</title>
<body>
<P>You sent: <?php echo "$img1_name"; ?>, a
<?php echo "$img1_size"; ?>
byte file with a mime type of
<?php echo "$img1_type"; ?>.</p>
<?php
}
?>
</body>
</html>Code: Select all
tags added[/size]