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

Re: [bang-phpug] upload image error

Expand Messages
  • LINGAM RAVI KIRAN
    Hi Pritesh, try this code and let me know. Ur using the $iname which gives the whole path and we can t copy in a directory file having full path.
    Message 1 of 7 , Jun 27, 2006
    • 0 Attachment
      Hi Pritesh,

      try this code and let me know. Ur using the $iname which gives the whole path and we can't copy in a directory file having full path.

      <html>
      <body>
      <form action="addimg.php" method="post" enctype="multipart/form-data">
      <table>
      <tr>
      <td>Image Name : <input type="text" name="iname"></td></tr>
      <tr>
      <td>Image File : <input type="file" name="image1"></td>
      </tr>
      <tr>
      <td>Description : <textarea cols="10" rows="5" wrap="VIRTUAL" maxlength="255" name="description"></textarea>
      <tr>
      <td>
      <input type="submit" value="Upload" name="upload" />
      </td>
      </tr>
      </form>
      </body>
      </html>

      <?
      $conn=mysql_connect("localhost" ,"root","");
      mysql_select_db("test",$conn);
      ?>

      <?
      include("conn_connect.php" );
      if(($_FILES['image1']['type']=="image/gif") || ($_FILES['image1']['type']=="image/jpeg"))
      {
      $iname=$_POST['iname'];
      $imageFile = $_FILES['image1']['name'];
      echo "Name : ".$iname."<br />";
      echo "Size : ".$_FILES['image1']['size'] ."<br />";
      echo "Type : ".$_FILES['image1']['type'] ."<br />";
      $filename=$_SERVER['DOCUMENT_ROOT']."/";
      copy($_FILES['image1']['tmp_name'],$imageFile) or die("Counld not copy.");
      $strdescription = addslashes(nl2br($_POST['description']));
      $insert="insert into img_demo values ('','$iname','$imageFile','$strdescription')";
      mysql_query($insert,$conn) or die(mysql_error());
      echo "Copy done!";
      }
      else
      {
      echo "Please gif or jpeg file!";
      }
      ?>

      Check once and let me know.
      Bye

      ----- Original Message ----
      From: pritesh loke <priteshloke@...>
      To: bang-phpug@yahoogroups.com
      Sent: Tuesday, June 27, 2006 9:56:11 PM
      Subject: Re: [bang-phpug] upload image error


      Hello sir
      I used this code but still they not storing the path in the database . even i am also changing the imaga name but still they not insert in the database.



      Thank you

      ansar ansar <ansarahmed_8@ yahoo.co. in> wrote: Hi pritesh,

      use the below code i am using it and getting file in $_FILES

      <form enctype="multipart/ form-data" action="xml. php" method="POST" >
      Send this file: <input name="userfile" type="file" />
      <input type="submit" value="Send File" />
      </form>


      pritesh loke <priteshloke@ yahoo.com> wrote: Hello to all
      pls check my code i write for upload image but they not get file in $_FILES function
      upload.php
      <html>

      <form action="addimg. php" method="post" >
      <table>
      <tr>
      <td>Image Name : <input type="text" name="iname" /></td</tr>
      <tr>
      <td>Image File : <input type="file" name="image1" /></td>
      </tr>
      <tr>
      <td>Description : <textarea cols="10" rows="5" wrap="VIRTUAL" maxlength="255" name="description" ></textarea>
      <tr>
      <td>
      <input type="submit" value="Upload" name="upload" />
      </td>
      </tr>
      </form>

      </html>

      addimg.php
      <?
      include("conn_ connect.php" );
      if(($_FILES[ 'image1'] ['type']= ="image/gif" ))
      {
      $iname=$_POST[ 'iname'];
      $imageFile = $_FILES['image1' ]['$iname' ];
      echo "Name : ".$iname."<br />";
      echo "Size : ".$_FILES['image1' ]['size'] ."<br />";
      echo "Type : ".$_FILES['image1' ]['type'] ."<br />";
      copy($_FILES[ 'image1'] ['tmp_name' ],"http://localhost/ newphp/".$_FILES['image1' ]['$iname' ]) or die("Counld not copy.") ;
      $strdescription = addslashes(nl2br( $_POST['descript ion']));

      $insert="insert into img_demo values('','$ iname','$ imageFile' ,'$strdescriptio n')";
      mysql_query( $insert,$ conn);
      echo "Copy done!";
      }
      else
      {
      echo "Please gif or jpeg file!";
      }?>

      conn_connect. php
      <?
      $conn=mysql_ connect(" localhost" ,"root"," pritesh") ;
      mysql_select_ db("property" ,$conn);
      ?>

      data file
      create table img_demo(
      id integer primary key auto_increment,
      iname varchar(100) ,
      iadd varchar(200) ,
      description text);

      Pls run and tell me the error.
      Thank you



      ------------ --------- --------- ---
      Yahoo! Groups gets better. Check out the new email design. Plus theres much more to come.

      [Non-text portions of this message have been removed]






      ------------ --------- --------- ---
      Yahoo! India Answers: Share what you know. Learn something new Click here
      Catch all the FIFA World Cup 2006 action on Yahoo! India Click here

      [Non-text portions of this message have been removed]





      ____________ _________ _________ _________ _________ __
      Do You Yahoo!?
      Tired of spam? Yahoo! Mail has the best spam protection around
      http://mail. yahoo.com

      [Non-text portions of this message have been removed]




      [Non-text portions of this message have been removed]
    • ravi kiran
      Hi Pritesh, try this code and let me know. Ur using the $iname which gives the whole path and we can t copy in a directory file having full path.
      Message 2 of 7 , Jun 28, 2006
      • 0 Attachment
        Hi Pritesh,

        try this code and let me know. Ur using the $iname which gives the
        whole path and we can't copy in a directory file having full path.

        <html>
        <body>
        <form action="addimg. php" method="post" enctype="multipart/ form-
        data" >
        <table>
        <tr>
        <td>Image Name : <input type="text" name="iname" ></td></tr>
        <tr>
        <td>Image File : <input type="file" name="image1" ></td>
        </tr>
        <tr>
        <td>Description : <textarea cols="10" rows="5" wrap="VIRTUAL"
        maxlength="255" name="description" ></textarea>
        <tr>
        <td>
        <input type="submit" value="Upload" name="upload" />
        </td>
        </tr>
        </form>
        </body>
        </html>

        <?
        $conn=mysql_ connect(" localhost" ,"root","");
        mysql_select_ db("test" ,$conn);
        ?>

        <?
        include("conn_ connect.php" );
        if(($_FILES[ 'image1'] ['type']= ="image/gif" ) || ($_FILES['image1' ]
        ['type'] =="image/ jpeg"))
        {
        $iname=$_POST[ 'iname'];
        $imageFile = $_FILES['image1' ]['name'] ;
        echo "Name : ".$iname."<br />";
        echo "Size : ".$_FILES['image1' ]['size'] ."<br />";
        echo "Type : ".$_FILES['image1' ]['type'] ."<br />";
        $filename=$_ SERVER['DOCUMENT _ROOT']." /";
        copy($_FILES[ 'image1'] ['tmp_name' ],$imageFile) or die("Counld not
        copy.");
        $strdescription = addslashes(nl2br( $_POST['descript ion']));
        $insert="insert into img_demo values
        ('','$iname' ,'$imageFile' ,'$strdescriptio n')";
        mysql_query( $insert,$ conn) or die(mysql_error( ));
        echo "Copy done!";
        }
        else
        {
        echo "Please gif or jpeg file!";
        }
        ?>

        Check once and let me know.
        Bye



        --- In bang-phpug@yahoogroups.com, pritesh loke <priteshloke@...>
        wrote:
        >
        > Hello to all
        > pls check my code i write for upload image but they not get
        file in $_FILES function
        > upload.php
        > <html>
        >
        > <form action="addimg.php" method="post">
        > <table>
        > <tr>
        > <td>Image Name : <input type="text" name="iname" /></td</tr>
        > <tr>
        > <td>Image File : <input type="file" name="image1" /></td>
        > </tr>
        > <tr>
        > <td>Description : <textarea cols="10" rows="5" wrap="VIRTUAL"
        maxlength="255" name="description" ></textarea>
        > <tr>
        > <td>
        > <input type="submit" value="Upload" name="upload" />
        > </td>
        > </tr>
        > </form>
        >
        > </html>
        >
        > addimg.php
        > <?
        > include("conn_connect.php");
        > if(($_FILES['image1']['type']=="image/gif"))
        > {
        > $iname=$_POST['iname'];
        > $imageFile = $_FILES['image1']['$iname'];
        > echo "Name : ".$iname."<br />";
        > echo "Size : ".$_FILES['image1']['size']."<br />";
        > echo "Type : ".$_FILES['image1']['type']."<br />";
        > copy($_FILES['image1']
        ['tmp_name'],"http://localhost/newphp/".$_FILES['image1']['$iname'])
        or die("Counld not copy.") ;
        > $strdescription = addslashes(nl2br($_POST['description']));
        >
        > $insert="insert into img_demo values
        ('','$iname','$imageFile','$strdescription')";
        > mysql_query($insert,$conn);
        > echo "Copy done!";
        > }
        > else
        > {
        > echo "Please gif or jpeg file!";
        > }?>
        >
        > conn_connect.php
        > <?
        > $conn=mysql_connect("localhost","root","pritesh");
        > mysql_select_db("property",$conn);
        > ?>
        >
        > data file
        > create table img_demo(
        > id integer primary key auto_increment,
        > iname varchar(100),
        > iadd varchar(200),
        > description text);
        >
        > Pls run and tell me the error.
        > Thank you
        >
        >
        >
        >
        > ---------------------------------
        > Yahoo! Groups gets better. Check out the new email design. Plus
        there's much more to come.
        >
        > [Non-text portions of this message have been removed]
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.