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