You are here: Re: DB cuts off data « All PHP « IT news, forums, messages
Re: DB cuts off data

Posted by Dave Nash on 01/11/07 10:21

On Thu, 11 Jan 2007 10:14:27 +0000, Geoff Berrow
<blthecat@ckdog.co.uk> wrote:

>Message-ID: <7psbq21eearnra2fca2997q24k2flfhfoe@4ax.com> from Dave Nash
>contained the following:
>
>>I have a script which uploads an image to a db.
>Are you uploading the image or a reference to the image?

Im uploading an imaeg to a folder and a reference to it in the db.
Its actually a script which is editing an existing image.

see below.

<?php

/* A function for moving file uploads, please make sure the
destination directory has directory permissions set (777) */

function move_upload( $file, $dest, $overwrite = false )
{

if ($file["error"] == UPLOAD_ERR_OK)
{
if(!file_exists( $dest.$file["name"] ) || $overwrite)
{
if (move_uploaded_file( $file["tmp_name"],
$dest.$file["name"] ))
{
$upload_feedback .= "The file " . $file["name"] .
" was successfully uploaded";
$error = FALSE;
}
else
{
$upload_feedback .= "The file " . $file["name"] .
" could not be moved";
$error = TRUE;
}
}
else
{
$upload_feedback .= "The file " . $file["name"] . "
already exists, please check the overwrite option if you wish to
replace it";
$error = TRUE;
}
}
else
{
switch ($file["error"])
{
case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE:
$upload_feedback .= "The file " . $file["name"] .
" is to large to be uploaded<br />";
$error = TRUE;
break;

case UPLOAD_ERR_PARTIAL:
$upload_feedback .= "The file" . $file["name"] . "
was interrupted while uploading, please try again<br />";
$error = TRUE;
break;
}
}

return array( "error" => $error, "feedback" =>
$upload_feedback ); //return message plus error status
}

/* All of the uploaded images */
$image = $_FILES["image"];

/* Destination directory */
$destination = "../upload/";

/* Call the function to move the files */
move_upload( $image, $destination );
?>
<?php
$query="UPDATE categories SET catname='$ud_catname',
image='{$ud_image["name"]}', parentid='$parentid' WHERE
catid='$ud_catid'";
@mysql_select_db($database) or die( "Unable to select database");
mysql_query($query);
echo " <table width=\"100%\" border=\"0\" cellspacing=\"1\"
cellpadding=\"3\">
<tr>
<th scope=\"col\"><div align=\"left\" class=\"textstandard\">The
Category was succesfully edited</div></th>
</tr>
</table>";
?>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация