NOT an easy upload
| From: | César Aracena | Date: | Mon, 22 Jul 2002 02:44:01 +0000 |
| Subject: | NOT an easy upload | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-108797@lists.php.net to get a copy of this message | ||
Hi all. Im trying to handle a picture upload. So far, Ive made my
script store it where I want with the name I want. The only problem now,
is that it should store that given name into a MySQL DB table
I tried
it by calling a function which stores the picture and returns a variable
called $picname then use an UPDATE statement but that variable isnt
passed
any ideas? The code looks like this:
function pic_upload($userid)
{
if (is_uploaded_file($_FILES['devpicture']['tmp_name']))
{
$filename = $_FILES['devpicture']['tmp_name'];
$realname = $_FILES['devpicture']['name'];
$username = $userid.".jpg";
copy($_FILES['devpicture']['tmp_name'],
"c:/apache/htdocs/os-seek/photos\\".$username);
$username;
}
else
{
echo "Possible file upload attack: filename
".$_FILES['devpicture']['name'].".<br>";
}
}
-------------------------------------------
and then the updating
-------------------------------------------
pic_upload($id);
$query = "UPDATE os_developers SET devpicture = '$username' WHERE devid
= $id";
$result = mysql_query($query) or die(mysql_error());
Thanks in advance,
Cesar Aracena
CE / MCSE+I
Neuquen, Argentina
+54.299.6356688
+54.299.4466621