Truncated post in firefox

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Cameron

    Truncated post in firefox

    Hi All,
    Am having troubles posting a filename in firefox 1.0. It seems my
    variable (which contains a slash) is truncated but only in firefox.
    I'm running apache & php4.3.9 on windows XP. magic_quotes_gp c is off
    and I've been googling around for half a day without any luck. The
    code is below:

    <?php
    $strDesc = $_REQUEST['strDesc'];
    $fileUpload = $_REQUEST['fileUpload'];
    $fileUpload_typ e;

    if(empty($strDe sc) || $fileUpload == "none")
    die("You must enter both a description and file");

    // Database connection variables
    $dbServer = "localhost" ;
    $dbDatabase = "file_repositor y";
    $dbUser = "root";
    $dbPass = "";

    $fileContent = implode('', file($fileUploa d));
    $fileContent = addslashes($fil eContent);

    $sConn = mysql_connect($ dbServer, $dbUser, $dbPass)
    or die("Couldn't connect to database server");
    $dConn = mysql_select_db ($dbDatabase, $sConn)
    or die("Couldn't connect to database $dbDatabase");

    $dbQuery = "INSERT INTO myTexts VALUES ";
    $dbQuery .= "(0, '$strDesc', '$fileContent', '$fileUpload_ty pe')";
    mysql_query($db Query) or die("Couldn't add file to database");
    echo var_dump($fileU pload);
    echo "<h1>File Uploaded</h1>";
    echo "The details of the uploaded file are shown below:<br><br>" ;
    echo "<b>File name:</b> $fileUpload_nam e <br>";
    echo "<b>Uploade d to:</b> $fileUpload <br><br>";
    echo "<a href='uploadfil e.php'>Add Another File</a>";
    ?>

    I've tested this in ie and opera and it works in both however firefox
    does something funny. If I specify fileUpload as "C:\Document1.t xt" on
    the previous page, var_dump() then shows that $fileUpload is a
    string(16) in opera and ie but only a string(13) in firefox
    (specifically, firefox sees "Document1.txt" ). I've taken most of this
    from a tutorial located at:

    Any help appreciated,
    Thankyou.
    Cameron

  • Daniel Tryba

    #2
    Re: Truncated post in firefox

    Cameron <fordcameron@gm ail.com> wrote:[color=blue]
    > $strDesc = $_REQUEST['strDesc'];
    > $fileUpload = $_REQUEST['fileUpload'];
    > $fileUpload_typ e;[/color]

    [snip]
    [color=blue]
    > I've tested this in ie and opera and it works in both however firefox
    > does something funny. If I specify fileUpload as "C:\Document1.t xt" on
    > the previous page, var_dump() then shows that $fileUpload is a
    > string(16) in opera and ie but only a string(13) in firefox
    > (specifically, firefox sees "Document1.txt" ). I've taken most of this
    > from a tutorial located at:
    > http://www.devarticles.com/c/a/MySQL...PHP-and-MySQL/[/color]

    What is the purpose of this script? AFAIK it's used to add a file
    _on the server_ to the database. If you want to upload files from a
    client this is not a correct script
    (http://nl3.php.net/manual/en/features.file-upload.php explains how to
    do that).

    IMHO FireFox is correct, the server has no business knowing the path to
    a file on a client.

    Comment

    • Cameron

      #3
      Re: Truncated post in firefox

      Thanx sorting me out Daniel. Sorry, bit of a newbie

      Comment

      • Cameron

        #4
        Re: Truncated post in firefox

        An interesting point however - if I copy & paste the URL out of ie the
        script will work OR if I change "\" to "/" in the form, mozilla can
        then see the file.
        hmmm...
        either it doesn't matter now =)

        Comment

        • Geoff Berrow

          #5
          Re: Truncated post in firefox

          I noticed that Message-ID:
          <1102995380.971 669.75850@f14g2 000cwb.googlegr oups.com> from Cameron
          contained the following:
          [color=blue]
          >Thanx sorting me out Daniel. Sorry, bit of a newbie[/color]

          Also consider simply storing the path to the file in the database rather
          than the file itself. Many find that easier.

          --
          Geoff Berrow (put thecat out to email)
          It's only Usenet, no one dies.
          My opinions, not the committee's, mine.
          Simple RFDs http://www.ckdog.co.uk/rfdmaker/

          Comment

          Working...