PHP version problem...please help!!
Posted: Thu Apr 06, 2006 4:34 pm
Hi i am a newbie so go easy on me
I am running
Apache/1.3.11
PHP/5.0.5
I have a script that uploads a zip file and stores it as binary data into MySQL. I thought the code wasnt working until two other people i asked ran it on their own personal servers and it works fine. The problem is, it wont work on mine and it is driving me crazy to the point i think im gonna go insane.
I am using a university computers so im not sure if its the way these are configured or the versions not be aligned with the code.
I suspect its the way i am passing the file from the html page into the php.
Here is the code:
binary_form.html:
add_binary_data.php:
The problem is this, it is simply not going into the IF statement and is therefore not setting $binary_File. I wonder with my version should i be posting or getting it differently?? i.e.
Those that it worked on are running versions
Apache 1.3.34
PHP 4.4.2
Any help would be appreciated, i am going out my mind as to why this wont work.
Thanks alot
I am running
Apache/1.3.11
PHP/5.0.5
I have a script that uploads a zip file and stores it as binary data into MySQL. I thought the code wasnt working until two other people i asked ran it on their own personal servers and it works fine. The problem is, it wont work on mine and it is driving me crazy to the point i think im gonna go insane.
I am using a university computers so im not sure if its the way these are configured or the versions not be aligned with the code.
I suspect its the way i am passing the file from the html page into the php.
Here is the code:
binary_form.html:
Code: Select all
<HTML>
<TITLE>Upload your files</TITLE>
<BODY>
<font face=verdana size=2>
<FORM METHOD="post" ACTION="add_binary_data.php" ENCTYPE="multipart/form-data">
<INPUT TYPE="hidden" NAME="MAX_FILE_SIZE" VALUE="500000">
<!--
Set the size of MAX_FILE_SIZE I have set it to approx 500KB means when we add
binary data add.php will check if the binaryfile size is > MAX_FILE_SIZE it wont allow
this is just a precaution so that users do not upload very large files.
-->
<INPUT TYPE="hidden" NAME="action" VALUE="upload">
<TABLE BORDER="1" cellspacing=0 cellpadding=0>
<TR>
<TD>File Description: </TD>
<TD><TEXTAREA NAME="file_description" ROWS="3" COLS="50"></TEXTAREA></TD>
</TR>
<TR>
<TD>File: </TD>
<TD><INPUT TYPE="file" NAME="binary_File"></TD>
</TR>
<TR>
<TD COLSPAN="2"><INPUT TYPE="submit" VALUE="Upload French"></TD>
</TR>
</TABLE>
</FORM>
</font>
</BODY>
</HTML>Code: Select all
<?php
$db = mysql_connect("localhost", "root","") or die(mysql_error());
mysql_select_db("test",$db) or die(mysql_error()); //connects to our mybuddy database
//$binary_File=$_POST['binary_File'];
$data = ('hello');
if (isset($binary_File) && $binary_File != "none")
{
$data = addslashes(fread(fopen($binary_File, "r"), filesize($binary_File)));
$strDescription = addslashes($file_description);
$sql = "INSERT INTO binary_data_files ";
$sql .= "(description, bin_data, filename, filesize, filetype) ";
$sql .= "VALUES ('$strDescription', '$data', ";
$sql .= "'$binary_File_name', '$binary_File_size', '$binary_File_type')";
$result = mysql_query($sql, $db);
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' .$result;
die($message);
}
echo "<font face=verdana size=2>The file was successfully added to our database.<P>";
echo "<P><B>File Name: </B>". $binary_File_name;
echo "<P><B>File Size: </B>". $binary_File_size ." bytes (approx ". $binary_File_size/1024 ." KB)";
echo "<P><B>File Type: </B>". $binary_File_type;
}else{
echo $data;
}
mysql_close();
?>
</font>Code: Select all
if (isset($_GET['binary_File']) && ($_GET['binary_File']) != "none"){Apache 1.3.34
PHP 4.4.2
Any help would be appreciated, i am going out my mind as to why this wont work.
Thanks alot