If  you  Want to  upload  an  image  in   php  or save   any  folder  or  database  you  can  use  the  upload    script     
  for this  you  first  have to create the    upload  html  form    that is  like  
  with  html  tag :
 after   that  you  have to  use the  php   script   to upload the  perticular 
image file  
i.e
?php
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 20000))
  {
  if ($_FILES["file"]["error"] > 0)
    {
    echo "Error: " . $_FILES["file"]["error"] . "
";
    }
  else
    {
    echo "vikas: " . $_FILES["file"]["name"] . "
";
    echo "Type: " . $_FILES["file"]["type"] . "
";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb
";
    echo "Stored in: " . $_FILES["file"]["tmp_name"];
 if (file_exists("upload/" . $_FILES["file"]["name"]))
      {
      echo $_FILES["file"]["name"] . " already exists. ";
      }
    else
      {
      move_uploaded_file($_FILES["file"]["tmp_name"],
      "vikas/" . $_FILES["file"]["name"]);
      echo "Stored in: " . "vikas/" . $_FILES["file"]["name"];
      }
    }
  }
else
  {
  echo "Invalid file";
  }
?> 
 here we  check  the  condition  for the  file the  file is of  the  type    jpeg
gif  ,  or  pjpg  type  by   which  other  file show  invalid  
the give  file image uploaded  by  pressing the   submit  button  or it  save  in the   folder  vikas  as you already  created
 
 
What is meaning of ($_FILES["file"]["size"] < 20000) 2000 in above code ????
ReplyDelete$_file["file"] is the name of the given file and ["size] is the size of file which is not more than 20000 kb so its simply mean condition you can upload file of size less than 20000kb by this function
ReplyDeletethank for the comment
SO what it is means. .. Is this stop the file more then 20000kb on client side or it first uploaded to server then one can known about size ???
ReplyDeleteyes if you try to upload the file of size more than 20000kb then you unable to upload that check show invalid file so you unable to upload the file more than 20000kb
ReplyDelete