Jump to content

Can someone help me know what is wrong with this code. it does not uplaod picture to server.


reid_ron

Recommended Posts

When trying to upload a picture file it goes error:Failed to upload file. Contact Site admin to fix the problem

What am I doing wrong

 

=======================

<?php

include 'db.php';

$id=@$_GET['id'];

$ya=mysql_query("select * from `registeronline` where user_id='$id'");
$yb=mysql_fetch_array($data);

$val= '$id'+2400241106;


if (!isset($_POST["Submit"])) {
echo "";
}else{
$file=@$_POST['pix'];

if (isset($HTTP_POST_FILES["pix"])){
                    $upload_type =$HTTP_POST_FILES["pix"]["type"];
                    $upload_name=$HTTP_POST_FILES["pix"]["name"];
                    $upload_size=$HTTP_POST_FILES["pix"]["size"];
                    $upload_tmp_name=$HTTP_POST_FILES["pix"]["tmp_name"];
                
                         }
                    else
                        {
                         echo "" ;
                         }
                     if ($userfile_size >250000){$msg=$msg."Your uploaded file size is more than 250KB so please reduce the file size and then upload. Visit the help page to know how to reduce the file size.<BR>";

$file_upload="false";}


if (!($userfile_type =="image/pjpeg" OR $userfile_type=="image/gif")){$msg=$msg."Your uploaded file must be of JPG or GIF. Other file types are not allowed<BR>";
$file_upload="false";}


$add="upload/$userfile_name"; // the path with the file name where the file will be stored, upload is the directory name.


if(move_uploaded_file ($userfile, $add)){
// Your Picture has been uploaded successfully.
}else{echo "Failed to upload file. Contact Site admin to fix the problem";}



   



$z=mysql_query("update `registeronline`
set
pix='$file'
where `user_id`='$id'
");


if (!$z ) {
echo "<script>alert('Update Not Successful')</script>";
}else{



}
}
 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.