Even een vraag. Wanneer ik bijgevoegde afbeelding (jpg) uplaod naar mijn database (blob-veld) dan ziet deze er ineens zo uit:
http://cms.quattronet.nl/output/productfoto.php?id=12
Iemand enig idee hoe dit kan? Dit is de code:
PHP Code:
$photoFileName = $_FILES['product_image']['name'];
if ($photoFileName) {
$aFileNameParts = explode(".", $photoFileName);
$sFileExtension = end($aFileNameParts);
if ($sFileExtension != "jpg" && $sFileExtension != "JPEG" && $sFileExtension != "JPG") {
die ("Kies een JPG voor de foto");
}
$sTempFileName = $_FILES['product_image']['tmp_name']; // temporary file at server side
$oTempFile = fopen($sTempFileName, "r");
$sBinaryPhoto = fread($oTempFile, fileSize($sTempFileName));
// Try to read image
$old_error_reporting = error_reporting(E_ALL & ~(E_WARNING)); // ingore warnings
$oSourceImage = imagecreatefromstring($sBinaryPhoto); // try to create image
error_reporting($old_error_reporting);
$nWidth = imagesx($oSourceImage); // get original source image width
$nHeight = imagesy($oSourceImage); // and height
// create small thumbnail
$nDestinationWidth = 1000;
$nDestinationHeight = 750;
//$oDestinationImage = imagecreatetruecolor($nDestinationWidth, $nDestinationHeight);
$oDestinationImage = imagecreate($nDestinationWidth, $nDestinationHeight);
/*$oResult = imagecopyresampled(
$oDestinationImage, $oSourceImage,
0, 0, 0, 0,
$nDestinationWidth, $nDestinationHeight,
$nWidth, $nHeight); // resize the image
*/
imagecopyresized(
$oDestinationImage, $oSourceImage,
0, 0, 0, 0,
$nDestinationWidth, $nDestinationHeight,
$nWidth, $nHeight); // resize the image
ob_start(); // Start capturing stdout.
imageJPEG($oDestinationImage); // As though output to browser.
$sBinaryThumbnail = ob_get_contents(); // the raw jpeg image data.
ob_end_clean(); // Dump the result so it does not screw other output.
$sBinaryThumbnail = addslashes($sBinaryThumbnail);
mysql_query("
INSERT INTO `quattrocms_shop_products` (
`product_id` ,
`product_company_id` ,
`product_category_id` ,
`product_sequence` ,
`product_title` ,
`product_price` ,
`product_stock` ,
`product_weight` ,
`product_description` ,
`product_image`
) VALUES (
NULL ,
'".$_COOKIE['login_company_id']."',
'".$_GET['categorie']."',
'".$_POST['product_sequence']."',
'".addslashes($_POST['product_title'])."',
'".$_POST['product_price']."',
'".$_POST['product_stock']."',
'".$_POST['product_weight']."',
'".addslashes($_POST['product_description'])."',
'".$sBinaryThumbnail."'
);
");
Header ("Location: ./?do=".$_GET['do']."&go=producten&categorie=".$_GET['categorie']."");
}
- blob image probleem
-
639 × bekeken sinds 04-01-2010, 20:03 #1
blob image probleem
-
In de schijnwerper
-
04-01-2010, 20:05 #2
- Berichten
- 400
- Lid sinds
- 15 Jaar
Dit is trouwens niet bij alle afbeeldingen die ik upload. Vele laad ie wel normaal zien. Maar ook heel veel niet.
-
04-01-2010, 20:05 #3
- Berichten
- 95
- Lid sinds
- 18 Jaar
Heel snel even gegoogle'd, maar probeer deze functie eens? http://www.php.net/manual/en/functio...etruecolor.php
-
04-01-2010, 20:07 #4
- Berichten
- 400
- Lid sinds
- 15 Jaar
Heel snel even gegoogle'd, maar probeer deze functie eens? http://www.php.net/manual/en/functio...etruecolor.php
PHP Code:<?php
header("Content-type: image/jpeg"); // act as a jpg file to browser
$nId = $_GET['id'];
require_once('../includes/connectie_database.php');
$sQuery = "SELECT * FROM quattrocms_shop_products WHERE product_id = $nId";
$oResult = mysql_query($sQuery);
$aRow = mysql_fetch_array($oResult);
$sJpg = $aRow["product_image"];
echo $sJpg;
?>
-
04-01-2010, 20:10 #5
- Berichten
- 330
- Lid sinds
- 18 Jaar
PHP Code:<?
$photoFileName = $_FILES['product_image']['name'];
if ($photoFileName) {
$aFileNameParts = explode(".", $photoFileName);
$sFileExtension = end($aFileNameParts);
if ($sFileExtension != "jpg" && $sFileExtension != "JPEG" && $sFileExtension != "JPG") {
die ("Kies een JPG voor de foto");
}
$sTempFileName = $_FILES['product_image']['tmp_name']; // temporary file at server side
$oTempFile = fopen($sTempFileName, "r");
$sBinaryPhoto = fread($oTempFile, fileSize($sTempFileName));
// Try to read image
$old_error_reporting = error_reporting(E_ALL & ~(E_WARNING)); // ingore warnings
$oSourceImage = imagecreatefromstring($sBinaryPhoto); // try to create image
error_reporting($old_error_reporting);
$nWidth = imagesx($oSourceImage); // get original source image width
$nHeight = imagesy($oSourceImage); // and height
// create small thumbnail
$nDestinationWidth = 1000;
$nDestinationHeight = 750;
$oDestinationImage = imagecreatetruecolor($nDestinationWidth, $nDestinationHeight);
/*$oResult = imagecopyresampled(
$oDestinationImage, $oSourceImage,
0, 0, 0, 0,
$nDestinationWidth, $nDestinationHeight,
$nWidth, $nHeight); // resize the image
*/
imagecopyresized(
$oDestinationImage, $oSourceImage,
0, 0, 0, 0,
$nDestinationWidth, $nDestinationHeight,
$nWidth, $nHeight); // resize the image
ob_start(); // Start capturing stdout.
imageJPEG($oDestinationImage); // As though output to browser.
$sBinaryThumbnail = ob_get_contents(); // the raw jpeg image data.
ob_end_clean(); // Dump the result so it does not screw other output.
$sBinaryThumbnail = addslashes($sBinaryThumbnail);
mysql_query("
INSERT INTO `quattrocms_shop_products` (
`product_id` ,
`product_company_id` ,
`product_category_id` ,
`product_sequence` ,
`product_title` ,
`product_price` ,
`product_stock` ,
`product_weight` ,
`product_description` ,
`product_image`
) VALUES (
NULL ,
'".$_COOKIE['login_company_id']."',
'".$_GET['categorie']."',
'".$_POST['product_sequence']."',
'".addslashes($_POST['product_title'])."',
'".$_POST['product_price']."',
'".$_POST['product_stock']."',
'".$_POST['product_weight']."',
'".addslashes($_POST['product_description'])."',
'".$sBinaryThumbnail."'
);
");
Header ("Location: ./?do=".$_GET['do']."&go=producten&categorie=".$_GET['categorie']."");
}
-
11-01-2010, 10:35 #6
- Berichten
- 400
- Lid sinds
- 15 Jaar
Nu worden foto's zo geupload: http://www.quattronet.nl/ontwikkelin...tami/index.php
iemand enig idee hoe dit kan?
-
11-01-2010, 10:43 #7
- Berichten
- 95
- Lid sinds
- 18 Jaar
http://stackoverflow.com/questions/4...ql-data-column
Je moet er even een MEDIUM of LONGBLOB van maken.
-
11-01-2010, 11:05 #8
- Berichten
- 400
- Lid sinds
- 15 Jaar
http://stackoverflow.com/questions/4...ql-data-column
Je moet er even een MEDIUM of LONGBLOB van maken.
Tags voor dit bericht
Plaats een
- + Advertentie
- + Onderwerp
Marktplaats
Webmasterforum
- Websites algemeen
- Sitechecks
- Marketing
- Domeinen algemeen
- Waardebepaling
- CMS
- Wordpress
- Joomla
- Magento
- Google algemeen
- SEO
- Analytics
- Adsense
- Adwords
- HTML / XHTML
- CSS
- Programmeren
- PHP
- Javascript
- JQuery
- MySQL
- Ondernemen algemeen
- Belastingen
- Juridisch
- Grafisch ontwerp
- Hosting Algemeen
- Hardware Info
- Offtopic