By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,959 Members | 1,160 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,959 IT Pros & Developers. It's quick & easy.

Truncated post in firefox

P: n/a
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_gpc 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_type;

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

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

$fileContent = implode('', file($fileUpload));
$fileContent = addslashes($fileContent);

$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_type')";
mysql_query($dbQuery) or die("Couldn't add file to database");
echo var_dump($fileUpload);
echo "<h1>File Uploaded</h1>";
echo "The details of the uploaded file are shown below:<br><br>";
echo "<b>File name:</b> $fileUpload_name <br>";
echo "<b>Uploaded to:</b> $fileUpload <br><br>";
echo "<a href='uploadfile.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.txt" 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/
Any help appreciated,
Thankyou.
Cameron

Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Cameron <fo*********@gmail.com> wrote:
$strDesc = $_REQUEST['strDesc'];
$fileUpload = $_REQUEST['fileUpload'];
$fileUpload_type;
[snip]
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.txt" 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/


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.
Jul 17 '05 #2

P: n/a
Thanx sorting me out Daniel. Sorry, bit of a newbie

Jul 17 '05 #3

P: n/a
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 =)

Jul 17 '05 #4

P: n/a
I noticed that Message-ID:
<11*********************@f14g2000cwb.googlegroups. com> from Cameron
contained the following:
Thanx sorting me out Daniel. Sorry, bit of a newbie


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/
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.