RE: [PHP] upload image
| From: | Peter Lauri | Date: | Thu, 24 Aug 2006 07:47:51 +0000 |
| Subject: | RE: [PHP] upload image | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-241072@lists.php.net to get a copy of this message | ||
Maybe this will help you:
$name = mysql_escape_string($_POST['doc_filename'][$key]);
$author = mysql_escape_string($_POST['doc_filename_author'][$key]);
$filename = mysql_escape_string($value);
$filetype = mysql_escape_string($_FILES['doc_attach']['type'][$key]);
$filesize = mysql_escape_string($_FILES['doc_attach']['size'][$key]);
$filedata = addslashes (fread(fopen
($_FILES['doc_attach']['tmp_name'][$key], "r"),
filesize($_FILES['doc_attach']['tmp_name'][$key])));
$Query = "INSERT INTO filestorage (name, author, filename, filetype,
filesize, filedata) VALUES ('$name', '$author', '$filename',
'$filetype',
'$filesize', '{$filedata}')";
/Peter
-----Original Message-----
From: Sonja [mailto:sonja@eu-softing.com]
Sent: Thursday, August 24, 2006 2:38 PM
To: php-general@lists.php.net
Subject: [PHP] upload image
Hi,
I have problems with uploading image, here is the code
if(isset($_POST['txtTitle']))
{
$albumId = $_POST['cboAlbum'];
$imgTitle = $_POST['txtTitle'];
$imgDesc = $_POST['mtxDesc'];
$images = uploadImage('fleImage', GALLERY_IMG_DIR);
if ($images['image'] == '' && $images['thumbnail'] ==
'') {
echo "Error uploading file";
exit;
}
$image = $images['image'];
$thumbnail = $images['thumbnail'];
if (!get_magic_quotes_gpc()) {
$albumName = addslashes($albumName);
$albumDesc = addslashes($albumDesc);
$imgPath = addslashes($imgPath);
}
$sql = "INSERT INTO tbl_image (im_album_id, im_title,
im_description,
im_image, im_thumbnail, im_date)
VALUES ($albumId, '$imgTitle', '$imgDesc', '$image',
'$thumbnail',
NOW())";
mysql_query($sql) or die('Error, add image failed : ' . mysql_error());
echo
"<script>window.location.href='index.php?page=list-image&album=$albumId';</s
cript>";
exit;
}
when I upload a picture return me error uploadin image.
Thanks
--
View this message in context:
http://www.nabble.com/upload-image-tf2157181.html#a5959218
Sent from the PHP - General forum at Nabble.com.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php