Loading ...
Sorry, an error occurred while loading the content.

Re: Upload script problem

Expand Messages
  • Chaitanya Yanamadala
    Hai Dudes Finally i have figured out the issue in my code. The problem was with the i
    Message 1 of 6 , Feb 2, 2010
    • 0 Attachment
      Hai Dudes
      Finally i have figured out the issue in my code. The problem was with the
      <input type="hidden" name="MAX_FILE_SIZE" value="9999999999999999" />
      i have mentioned this as 100000 previously and so it could not able to
      upload any file less than an MB..
      Finally figured it out..

      this should be the code..

      <form enctype="multipart/form-data" action="upload.php" method="POST">
      <input type="hidden" name="MAX_FILE_SIZE" value="9999999999999999" />
      Choose a file to upload: <input name="uploaded" type="file" /><br />
      <input type="submit" value="Upload File" />
      </form>
      <?php
      $host="localhost";
      $user="root";
      $pass="admin";
      $db="develop";
      mysql_connect($host,$user,$pass) or die(mysql_error());
      mysql_select_db($db) or die(mysql_error());
      $query="select type_name from filetype";
      $result=mysql_query($query);
      /*while($row = mysql_fetch_array($result))
      {
      //$ary[]=($row['number']);
      if($rand==$row['number'])
      {
      echo "The random number is there in the array";
      break;
      }
      // break;
      }*/
      ini_set("display_errors",1);
      error_reporting(E_ALL);
      $target = "upload/";
      $target = $target . basename( $_FILES['uploaded']['name']) ;
      $uploaded_type=strtolower(substr($_FILES['uploaded']['name'],strrpos($_FILES['uploaded']['name'],'.')+1));
      print_r($_FILES['uploaded']);
      echo "<br>FileX ".$uploaded_type;
      while($row = mysql_fetch_array($result))
      {
      if($uploaded_type==$row['type_name'])
      {

      if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
      {
      echo "The file ". basename( $_FILES['uploaded']['name']). " has
      been uploaded";
      break;
      }
      else
      {
      echo "Sorry, there was a problem uploading your file.";
      }

      }
      }
      //This is our limit file type condition
      /*if
      (($uploaded_type=="gif")||($uploaded_type=="jpg")||($uploaded_type=="png")||($uploaded_type=="pdf")||($uploaded_type=="doc"))
      {

      if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
      {
      echo "The file ". basename( $_FILES['uploaded']['name']). " has been
      uploaded";
      }
      else
      {
      echo "Sorry, there was a problem uploading your file.";
      }

      }
      else
      {
      echo "These files cannot be uploaded<br>";
      }*/
      ?>

      Chaitanya

      "A man can get discouraged many times but he is not a failure until he stops
      trying..."

      http://doiop.com/dr.virus.india

      http://www.drvirusindia.co.cc/

      http://chaitu09986025424.blog.co.in/

      http://9986025424.co.cc -- Live news channels


      On Tue, Feb 2, 2010 at 12:21 PM, Chaitanya Yanamadala <
      dr.virus.india@...> wrote:

      > Hai
      > I have created this code for uploading the files.It uploads the jpg, png
      > files correctly. but if i check with gif it is giving the problem. I have
      > checked that it is not creating a temp name for that file types, can any one
      > tell me y is this happening. here is the code.
      >
      >
      > <form enctype="multipart/form-data" action="upload_file.php" method="POST">
      > <input type="hidden" name="MAX_FILE_SIZE" value="100000" />
      > Choose a file to upload: <input name="uploaded" type="file" /><br />
      > <input type="submit" value="Upload File" />
      > </form>
      > <?php
      > ini_set("display_errors",1);
      > error_reporting(E_ALL);
      > $target = "upload/";
      > $target = $target . basename( $_FILES['uploaded']['name']) ;
      >
      > $uploaded_type=strtolower(substr($_FILES['uploaded']['name'],strrpos($_FILES['uploaded']['name'],'.')+1));
      > print_r($_FILES['uploaded']);
      > echo "111 ".$uploaded_type;
      >
      > //This is our limit file type condition
      > if
      > (($uploaded_type=="gif")||($uploaded_type=="jpg")||($uploaded_type=="png"))
      > {
      >
      > if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
      > {
      > echo "The file ". basename( $_FILES['uploaded']['name']). " has been
      > uploaded";
      > }
      > else
      > {
      > echo "Sorry, there was a problem uploading your file.";
      > }
      >
      > }
      > else
      > {
      > echo "These files cannot be uploaded<br>";
      > }
      > ?>
      >
      > Chaitanya
      >
      > "A man can get discouraged many times but he is not a failure until he
      > stops trying..."
      >
      > http://doiop.com/dr.virus.india
      >
      > http://www.drvirusindia.co.cc/
      >
      > http://chaitu09986025424.blog.co.in/
      >
      > http://9986025424.co.cc -- Live news channels
      >


      [Non-text portions of this message have been removed]
    • Chaitanya Yanamadala
      Hai Thank you for your reply dude. I have already figured it out.. Chaitanya A man can get discouraged many times but he is not a failure until he stops
      Message 2 of 6 , Feb 2, 2010
      • 0 Attachment
        Hai
        Thank you for your reply dude. I have already figured it out..
        Chaitanya

        "A man can get discouraged many times but he is not a failure until he stops
        trying..."

        http://doiop.com/dr.virus.india

        http://www.drvirusindia.co.cc/

        http://chaitu09986025424.blog.co.in/

        http://9986025424.co.cc -- Live news channels


        On Tue, Feb 2, 2010 at 7:24 PM, Gurramq Anurag <gurram_anurag@...>wrote:

        >
        >
        > Can you say me the error you are getting
        >
        > Get your preferred Email name!
        > Now you can @... and @....
        > http://mail.promotions.yahoo.com/newdomains/aa/
        >
        > [Non-text portions of this message have been removed]
        >
        >
        >


        [Non-text portions of this message have been removed]
      • Udayakumar Sarangapani
        Hi, I have faced this problem in the beginning. So, before going to use the upload code, go through the manual to get more information about the upload file
        Message 3 of 6 , Feb 17, 2010
        • 0 Attachment
          Hi,

          I have faced this problem in the beginning. So, before going to use the
          upload code, go through the manual to get more information about the upload
          file error # and their descriptions.

          Once I have the same problem while my client uploading the flash file and i
          was not able to run it. Finally I found that errors in flash file.

          Thanks for sharing.

          -U

          On Tue, Feb 2, 2010 at 8:41 PM, Chaitanya Yanamadala <
          dr.virus.india@...> wrote:

          >
          >
          > Hai
          > Thank you for your reply dude. I have already figured it out..
          >
          > Chaitanya
          >
          > "A man can get discouraged many times but he is not a failure until he
          > stops
          > trying..."
          >
          > http://doiop.com/dr.virus.india
          >
          > http://www.drvirusindia.co.cc/
          >
          > http://chaitu09986025424.blog.co.in/
          >
          > http://9986025424.co.cc -- Live news channels
          >
          > On Tue, Feb 2, 2010 at 7:24 PM, Gurramq Anurag <gurram_anurag@...<gurram_anurag%40yahoo.com>
          > >wrote:
          >
          >
          > >
          > >
          > > Can you say me the error you are getting
          > >
          > > Get your preferred Email name!
          > > Now you can @... and @....
          > > http://mail.promotions.yahoo.com/newdomains/aa/
          > >
          > > [Non-text portions of this message have been removed]
          > >
          > >
          > >
          >
          > [Non-text portions of this message have been removed]
          >
          >
          >


          [Non-text portions of this message have been removed]
        Your message has been successfully submitted and would be delivered to recipients shortly.