Uploading Image using PHP and mySQL
am 19.02.2008 00:58:30 von Nasreen Laghari--0-1320658969-1203379110=:21466
Content-Type: text/plain; charset=us-ascii
Hi All,
First of all A very big thank you to all of you for solving my Password() encryption problem.
Now I'm stuck on new problem which is image not uploading. I'm using the following code.
Regards
Nasreen
include ("header.php");
include ("dbconnect.php");
$submit=$_REQUEST["submit"] ;
$aname=$_REQUEST["aname"];
$aboutu=$_REQUEST["urself"];
$file=$_REQUEST["file"];
$url_provided = $_REQUEST["url_provided"];
echo($aname);
if ($submit == "Sign!")
{
function getImageFile($file){
$takeFile = fopen($file, "r");
$file = fread($takeFile, filesize($file));
fclose($takeFile);
return $file;
}
function getfileType( $name ){
$name = explode(".", $name);
$name = array_reverse($name);
$name = $name[0];
return $name;
}
$allowedImageTypes = array("gif","jpg","png");
if(empty($_FILES['image_file']['tmp_name'])){
echo "File not uploaded";
}
else {
$fileType = $_FILES['file']['name'];
if(in_array(getfileType($fileType), $allowedImageTypes)){
$fileContent = getImageFile($_FILES['file']['tmp_name']);
$uploadedImage = chunk_split(base64_encode($fileContent));
$query = "INSERT INTO artist (name,about_u,imgdata, profile_url) VALUES('$aname','$aboutu','$uploadedImage','$url_provided')" ;
$result = mysql_query($query);
if(mysql_affected_rows() > 0){
echo "Image has been inserted succesfully";
}
else {
echo "Image can not be inserted check your submission";
}
}
else {
echo "This is not a true image type";
}
}
}
?>
Artist Profile Form
Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.
____________________________________________________________ ________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs
--0-1320658969-1203379110=:21466--