Menu

insert files (New)

Help
2008-05-28
2013-06-03
  • Hindarto gunawan

    I alrady changed to your advice but still error

    Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\AppServ\www\form\processor.php on line 9

    Admin
    There are excluded messages in this forum.
    insert files (New)
    By: Hindarto gunawan (hindarto) - 2008-05-24 05:46

    Dear admin,

    I put insert files submission on the form with others input rows, but several time submits i can not make any difference because the picture names changed into numeric file that hasn't relate with id or others variables. So i can which picture related with each data. Thanks

    RE: insert files (New)
    By: TNTEverett (tnteveret1 ) - 2008-05-27 05:18

    Look for the line in your processor.php that looks like this:
    $field_1_filename = "file_1_".date("sihdmY").substr($_FILES['field_1']['name'],strlen($_FILES['field_1']['name'])-4);

    The $field_1_filename variable must match the variable used to upload your file. Change the line to look like this:
    $field_1_filename = "$_FILES['field_1']['name'];
    This will not protect agains duplicate filenames unless you do something like this:
    $field_1_filename = "$_FILES['field_14']['name'].".".date("sihdmY");

     
    • TNTEverett

      TNTEverett - 2008-05-28

      These messages indicate some basic syntax error.  If you want to send me the process file I am sure I can straighten it out for you.  Otherwise send me the lines listed in your error messages. 

       
    • Hindarto gunawan

      Dear support, this is the process file, but this is the original one before i changed into what your describe. i delete the upgrade, after error happened. Thanks

      <?php

      $where_form_is="http://".$_SERVER['SERVER_NAME'].strrev(strstr(strrev($_SERVER['PHP_SELF']),"/"));

      session_start();
      if( ($_SESSION['security_code']==$_POST['security_code']) && (!empty($_POST['security_code'])) ) {
      // File upload handling
      if($_FILES['field_14']['name']!=''){
      $field_14_filename = "file_14_".date("sihdmY").substr($_FILES['field_14']['name'],strlen($_FILES['field_14']['name'])-4);
      if(!move_uploaded_file($_FILES['field_14']['tmp_name'], "./files/".$field_14_filename)){
      die("File " .  $_FILES['field_14']['name'] . " was not uploaded.");
      }
      }

      // File upload handling
      if($_FILES['field_15']['name']!=''){
      $field_15_filename = "file_15_".date("sihdmY").substr($_FILES['field_15']['name'],strlen($_FILES['field_15']['name'])-4);
      if(!move_uploaded_file($_FILES['field_15']['tmp_name'], "./files/".$field_15_filename)){
      die("File " .  $_FILES['field_15']['name'] . " was not uploaded.");
      }
      }

      // Checkbox handling
      $field_21_opts = $_POST['field_21'][0];

      include("config.inc.php");
      $link = mysql_connect($db_host,$db_user,$db_pass);
      if(!$link) die ('Could not connect to database: '.mysql_error());
      mysql_select_db($db_name,$link);
      $query = "INSERT into `".$db_table."` (field_1,field_2,field_3,field_4,field_5,field_6,field_7,field_8,field_9,field_10,field_11,field_12,field_13,field_14,field_15,field_16,field_17,field_18,field_19,field_20,field_21) VALUES ('" . $_POST['field_1'] . "','" . $_POST['field_2'] . "','" . $_POST['field_3'] . "','" . $_POST['field_4'] . "','" . $_POST['field_5'] . "','" . $_POST['field_6'] . "','" . $_POST['field_7'] . "','" . $_POST['field_8'] . "','" . $_POST['field_9'] . "','" . $_POST['field_10'] . "','" . $_POST['field_11'] . "','" . $_POST['field_12'] . "','" . $_POST['field_13'] . "','" . $_POST['field_14'] . "','" . $_POST['field_15'] . "','" . $_POST['field_16'] . "','" . $_POST['field_17'] . "','" . $_POST['field_18'] . "','" . $_POST['field_19'] . "','" . $_POST['field_20'] . "','" . $_POST['field_21'] . "')";
      mysql_query($query);
      mysql_close($link);

      include("confirm.html");
      }
      else {
      echo "Invalid Captcha String.";
      }

      ?>

       
      • TNTEverett

        TNTEverett - 2008-05-29

        Your original code line 9 looks like this:
        $field_14_filename = "file_14_".date("sihdmY").substr($_FILES['field_14']['name'],strlen($_FILES['field_14']['name'])-4);

        and for a file named "CN1J.pdf" it would have produced results like this:
        file_14_51380729052008.pdf

        If you modify line 9 to look like this:
        $field_14_filename = $_FILES['field_14']['name'].".".date("sihdmY");

        then for a file named "CN1J.pdf" it will produce results like this:
        CN1J.pdf.51380729052008

        You can see that the original file name is the same "CN1J.pdf" and that it has an additional time stamp ".51380729052008" that prevents over writing files with the same name. 

        This does work and only requires that you modify a single line of code in the processor.php file. 

         
    • Hindarto gunawan

      Sorry for made you inconvenient, but i really want to know the problem, this new error message ;

      Warning: move_uploaded_file(./files/Hindarto.jpg.49280729052008) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/klubmala/public_html/opening/iklan/processor.php on line 10

      Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpijo7B7' to './files/Hindarto.jpg.49280729052008' in /home/klubmala/public_html/opening/iklan/processor.php on line 10
      File Hindarto.jpg was not uploaded.

       
      • TNTEverett

        TNTEverett - 2008-05-29

        The files folder needs to have permissions set to 777.  If you are concerned about security of these files then also add a blank index.html file in this folder then add password protection to it so no one but you can access the folder from a web browser. 

         
    • Hindarto gunawan

      Thanks it's work...

      I want to know if this page have how to make report from php and login member..

      right now i made my web .. if success i will donate thks

      www.indonightclubs.com

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.