Insert filename, size file & modified date file into mysql database

Last post 03-21-2011, 2:20 PM by Eric. 5 replies.
Sort Posts: Previous Next
  •  02-18-2011, 9:40 AM 66291

    Insert filename, size file & modified date file into mysql database

     Hello there. I'm new comer. How to do simple php programming to insert filename, size file & modified date into mysql database?
     
    Thanks.
     
    Faisal Mustaffa
  •  02-18-2011, 9:52 AM 66292 in reply to 66291

    Re: Insert filename, size file & modified date file into mysql database

    Dear faisalmustaffa,
     
    Please refer to the following snippet:

    <?php require_once "phpuploader/include_phpuploader.php" ?>
    <?php session_start(); ?>
    <html>
    <head>
    <title>Example</title>
    </head>
    <body>
    <form name="theForm" action="1.php?postback=true" method="post">
    <h1>Example</h1>
    <table>
     <tr>
      <td>Subject:</td>
      <td><input name="subject" type="text" id="subject"
       style="width: 170px;" /></td>
     </tr>
     <tr>
      <td>From:</td>
      <td><input name="from" type="text" id="from" style="width: 170px;" />
      </td>
     </tr>
     <tr>
      <td>To:</td>
      <td><input name="to" type="text" id="to" style="width: 170px;" /></td>
     </tr>
    </table>
    <br />
    <br />
    <br />
    <?php
    $uploader=new PhpUploader();
    $uploader->MultipleFilesUpload=true;
    $uploader->Name="myuploader";
    $uploader->InsertText="Select multiple files (Max 1000M)";
    $uploader->MaxSizeKB=1024000;
    $uploader->Render();
    echo '<br \>';
    echo '<br \>';
    if(@$_POST["subject"]!=null)
    {
     echo $_POST["subject"];
     echo '<br \>';
    }
    if(@$_POST["from"]!=null)
    {
     echo $_POST["from"];
     echo '<br \>';
    }
    if(@$_POST["to"]!=null)
    {
     echo $_POST["to"];
     echo '<br \>';
    }
    $fileguid=@$_POST["myuploader"];   
    if($fileguid)   
    {   
        //get the uploaded file based on GUID   
        $mvcfile=$uploader->GetUploadedFile($fileguid);   
        if($mvcfile)   
        {   
            //Gets the name of the file.   
            echo($mvcfile->FileName);   
            echo "<br/>";
            //Gets the temp file path.   
            echo($mvcfile->FilePath);  
            echo "<br/>";
            //Gets the size of the file.   
            echo($mvcfile->FileSize);    
            echo "<br/>";
               
            //Copys the uploaded file to a new location.   
            //$mvcfile->CopyTo("/savefiles");  
           
            //Deletes this instance.   
            //$mvcfile->Delete();

            if ($mvcfile->FilePath<>""){
              $fp=fopen($mvcfile->FilePath,"r");
              $data=addslashes(fread($fp,filesize($mvcfile->FilePath)));
            $connect = @mysql_connect( "localhost", "root", "" );
          if ( ! $connect ) {
        die( "Couldn't connect to MySQL: ".mysql_error() );
       }
       $db = "cuteeditortest";
       @mysql_select_db( $db ) or die ( "Couldn't open $db: ".mysql_error() );
       $id=555;
          $sql="insert into image (id,photo) values('$id','$data')";
       
          mysql_query( $sql, $connect ) or die ( "INSERT error: ".mysql_error() );     
          mysql_close($connect);
            }
        }   
    }
    ?>
    </form>
    </body>
    </html>

    Thank you for asking
  •  02-19-2011, 3:44 AM 66300 in reply to 66292

    Re: Insert filename, size file & modified date file into mysql database

    Wow...fast reply...Will try this code...
     
    Thank you very much
     
    Faisal Mustaffa
  •  02-19-2011, 8:11 AM 66303 in reply to 66292

    Re: Insert filename, size file & modified date file into mysql database

    Great..it's working...Thank you very much Eric for your expertise.
     
    Best regards,
     
    Faisal Mustaffa
  •  03-18-2011, 3:57 PM 66749 in reply to 66292

    Re: Insert filename, size file & modified date file into mysql database

    Hi!
    I tryd but it somthig wrong with format in my MYsql
    photo
    ÿØÿà�JFIF��`�`��ÿÛ�C�
  •  03-21-2011, 2:20 PM 66781 in reply to 66749

    Re: Insert filename, size file & modified date file into mysql database

    Dear Guva,
     
    Can you describe "this wrong with format" in detail?
     
    Thank you for asking
View as RSS news feed in XML