Click here to Skip to main content
15,908,445 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all

i have a page which from an input i upload an image and save it to the database.

i tried that code :

PHP
$dir="./item/";
$PicUser = $_POST['userfile'];
if (!empty($PicUser))
{
$imgarr=getimagesize($PicUser);
echo $imgarr;
$imgarr=array("100","100","2");
if ($imgarr[0] <= 300 AND $imgarr[1] <= 300)
{
$id=@mysql_result(@mysql_query("select id from shop_item order by id desc"),0,0);
if (!is_uploaded_file ($PicUser))
{
$error_teks=" couldn't be copied !!";
}
if (is_uploaded_file ($PicUser))
{
$desfile="shop_$id.jpg";
move_uploaded_file($PicUser,$dir.$desfile) ;
}   
copy($PicUser, "item/shop_$id.jpg");
$image="item/shop_$id.jpg";
mysql_query("update shop_item set picture='$image' where id='$id'");
}
else
{
$error_teks="Can not upload file . Maximum size is 300x300";
}
}


the path is stored correctly , but the image itself doesn't be uploaded to the server.


Any Help ,please???


Thanks
Posted

1 solution

Uploaded files are in the $_FILES array[^], not in $_POST.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900