Help getting this upload file scrip around globals being off
- virose
- Novice


- Joined: Jul 20, 2005
- Posts: 27
- Loc: florida
- Status: Offline
Hi everyone
This script below is a upload a file to database script it works great with globals on.
But if you turn globals off. it dose nothing.
SO i need a work around for this code turn run with globals off.
Thanks in advanced for any help
Here is the code
if ($action == "upload") {
// ok, let's get the uploaded data and insert it into the db now
include "open_db.inc";
if (isset($binFile) && $binFile != "none") {
$data = addslashes(fread(fopen($binFile, "r"), filesize($binFile)));
$strDescription = addslashes(nl2br($txtDescription));
$sql = "INSERT INTO family_pics ";
$sql .= "(description, bin_data, filename, filesize, filetype) ";
$sql .= "VALUES ('$strDescription', '$data', ";
$sql .= "'$binFile_name', '$binFile_size', '$binFile_type')";
$result = mysql_query($sql, $db);
echo "Thank you. The new file was successfully added to our database.<br><br>";
echo "<a href='main.php'>Continue</a>";
}
mysql_close($db);
} else {
?>
<HTML>
<BODY>
<FORM METHOD="post" ACTION="add.php" ENCTYPE="multipart/form-data">
<INPUT TYPE="hidden" NAME="MAX_FILE_SIZE" VALUE="2000000">
<INPUT TYPE="hidden" NAME="action" VALUE="upload">
<TABLE BORDER="1">
<TR>
<TD>Description: </TD>
<TD><TEXTAREA NAME="txtDescription" ROWS="10" COLS="50"></TEXTAREA></TD>
</TR>
<TR>
<TD>File: </TD>
<TD><INPUT TYPE="file" NAME="binFile"></TD>
</TR>
<TR>
<TD COLSPAN="2"><INPUT TYPE="submit" VALUE="Upload"></TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
<?php
}
?>
This script below is a upload a file to database script it works great with globals on.
But if you turn globals off. it dose nothing.
SO i need a work around for this code turn run with globals off.
Thanks in advanced for any help
Here is the code
Code: [ Select ]
if ($action == "upload") {
// ok, let's get the uploaded data and insert it into the db now
include "open_db.inc";
if (isset($binFile) && $binFile != "none") {
$data = addslashes(fread(fopen($binFile, "r"), filesize($binFile)));
$strDescription = addslashes(nl2br($txtDescription));
$sql = "INSERT INTO family_pics ";
$sql .= "(description, bin_data, filename, filesize, filetype) ";
$sql .= "VALUES ('$strDescription', '$data', ";
$sql .= "'$binFile_name', '$binFile_size', '$binFile_type')";
$result = mysql_query($sql, $db);
echo "Thank you. The new file was successfully added to our database.<br><br>";
echo "<a href='main.php'>Continue</a>";
}
mysql_close($db);
} else {
?>
<HTML>
<BODY>
<FORM METHOD="post" ACTION="add.php" ENCTYPE="multipart/form-data">
<INPUT TYPE="hidden" NAME="MAX_FILE_SIZE" VALUE="2000000">
<INPUT TYPE="hidden" NAME="action" VALUE="upload">
<TABLE BORDER="1">
<TR>
<TD>Description: </TD>
<TD><TEXTAREA NAME="txtDescription" ROWS="10" COLS="50"></TEXTAREA></TD>
</TR>
<TR>
<TD>File: </TD>
<TD><INPUT TYPE="file" NAME="binFile"></TD>
</TR>
<TR>
<TD COLSPAN="2"><INPUT TYPE="submit" VALUE="Upload"></TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
<?php
}
?>
- if ($action == "upload") {
- // ok, let's get the uploaded data and insert it into the db now
- include "open_db.inc";
- if (isset($binFile) && $binFile != "none") {
- $data = addslashes(fread(fopen($binFile, "r"), filesize($binFile)));
- $strDescription = addslashes(nl2br($txtDescription));
- $sql = "INSERT INTO family_pics ";
- $sql .= "(description, bin_data, filename, filesize, filetype) ";
- $sql .= "VALUES ('$strDescription', '$data', ";
- $sql .= "'$binFile_name', '$binFile_size', '$binFile_type')";
- $result = mysql_query($sql, $db);
- echo "Thank you. The new file was successfully added to our database.<br><br>";
- echo "<a href='main.php'>Continue</a>";
- }
- mysql_close($db);
- } else {
- ?>
- <HTML>
- <BODY>
- <FORM METHOD="post" ACTION="add.php" ENCTYPE="multipart/form-data">
- <INPUT TYPE="hidden" NAME="MAX_FILE_SIZE" VALUE="2000000">
- <INPUT TYPE="hidden" NAME="action" VALUE="upload">
- <TABLE BORDER="1">
- <TR>
- <TD>Description: </TD>
- <TD><TEXTAREA NAME="txtDescription" ROWS="10" COLS="50"></TEXTAREA></TD>
- </TR>
- <TR>
- <TD>File: </TD>
- <TD><INPUT TYPE="file" NAME="binFile"></TD>
- </TR>
- <TR>
- <TD COLSPAN="2"><INPUT TYPE="submit" VALUE="Upload"></TD>
- </TR>
- </TABLE>
- </FORM>
- </BODY>
- </HTML>
- <?php
- }
- ?>
- Anonymous
- Bot


- Joined: 25 Feb 2008
- Posts: ?
- Loc: Ozzuland
- Status: Online
May 15th, 2009, 11:26 am
- dark_lord
- Graduate


- Joined: Jan 14, 2009
- Posts: 162
- Loc: India-Kolkata
- Status: Offline
i guess i told you
change this
to
change this
Code: [ Select ]
if ($action == "upload") {
// ok, let's get the uploaded data and insert it into the db now
include "open_db.inc";
if (isset($binFile) && $binFile != "none") {
$data = addslashes(fread(fopen($binFile, "r"), filesize($binFile)));
$strDescription = addslashes(nl2br($txtDescription));
$sql = "INSERT INTO family_pics ";
$sql .= "(description, bin_data, filename, filesize, filetype) ";
$sql .= "VALUES ('$strDescription', '$data', ";
$sql .= "'$binFile_name', '$binFile_size', '$binFile_type')";
$result = mysql_query($sql, $db);
echo "Thank you. The new file was successfully added to our database.<br><br>";
echo "<a href='main.php'>Continue</a>";
}
mysql_close($db);
} else {
?>
<HTML>
<BODY>
<FORM METHOD="post" ACTION="add.php" ENCTYPE="multipart/form-data">
<INPUT TYPE="hidden" NAME="MAX_FILE_SIZE" VALUE="2000000">
<INPUT TYPE="hidden" NAME="action" VALUE="upload">
<TABLE BORDER="1">
<TR>
<TD>Description: </TD>
<TD><TEXTAREA NAME="txtDescription" ROWS="10" COLS="50"></TEXTAREA></TD>
</TR>
<TR>
<TD>File: </TD>
<TD><INPUT TYPE="file" NAME="binFile"></TD>
</TR>
<TR>
<TD COLSPAN="2"><INPUT TYPE="submit" VALUE="Upload"></TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
<?php
}
?>
// ok, let's get the uploaded data and insert it into the db now
include "open_db.inc";
if (isset($binFile) && $binFile != "none") {
$data = addslashes(fread(fopen($binFile, "r"), filesize($binFile)));
$strDescription = addslashes(nl2br($txtDescription));
$sql = "INSERT INTO family_pics ";
$sql .= "(description, bin_data, filename, filesize, filetype) ";
$sql .= "VALUES ('$strDescription', '$data', ";
$sql .= "'$binFile_name', '$binFile_size', '$binFile_type')";
$result = mysql_query($sql, $db);
echo "Thank you. The new file was successfully added to our database.<br><br>";
echo "<a href='main.php'>Continue</a>";
}
mysql_close($db);
} else {
?>
<HTML>
<BODY>
<FORM METHOD="post" ACTION="add.php" ENCTYPE="multipart/form-data">
<INPUT TYPE="hidden" NAME="MAX_FILE_SIZE" VALUE="2000000">
<INPUT TYPE="hidden" NAME="action" VALUE="upload">
<TABLE BORDER="1">
<TR>
<TD>Description: </TD>
<TD><TEXTAREA NAME="txtDescription" ROWS="10" COLS="50"></TEXTAREA></TD>
</TR>
<TR>
<TD>File: </TD>
<TD><INPUT TYPE="file" NAME="binFile"></TD>
</TR>
<TR>
<TD COLSPAN="2"><INPUT TYPE="submit" VALUE="Upload"></TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
<?php
}
?>
- if ($action == "upload") {
- // ok, let's get the uploaded data and insert it into the db now
- include "open_db.inc";
- if (isset($binFile) && $binFile != "none") {
- $data = addslashes(fread(fopen($binFile, "r"), filesize($binFile)));
- $strDescription = addslashes(nl2br($txtDescription));
- $sql = "INSERT INTO family_pics ";
- $sql .= "(description, bin_data, filename, filesize, filetype) ";
- $sql .= "VALUES ('$strDescription', '$data', ";
- $sql .= "'$binFile_name', '$binFile_size', '$binFile_type')";
- $result = mysql_query($sql, $db);
- echo "Thank you. The new file was successfully added to our database.<br><br>";
- echo "<a href='main.php'>Continue</a>";
- }
- mysql_close($db);
- } else {
- ?>
- <HTML>
- <BODY>
- <FORM METHOD="post" ACTION="add.php" ENCTYPE="multipart/form-data">
- <INPUT TYPE="hidden" NAME="MAX_FILE_SIZE" VALUE="2000000">
- <INPUT TYPE="hidden" NAME="action" VALUE="upload">
- <TABLE BORDER="1">
- <TR>
- <TD>Description: </TD>
- <TD><TEXTAREA NAME="txtDescription" ROWS="10" COLS="50"></TEXTAREA></TD>
- </TR>
- <TR>
- <TD>File: </TD>
- <TD><INPUT TYPE="file" NAME="binFile"></TD>
- </TR>
- <TR>
- <TD COLSPAN="2"><INPUT TYPE="submit" VALUE="Upload"></TD>
- </TR>
- </TABLE>
- </FORM>
- </BODY>
- </HTML>
- <?php
- }
- ?>
to
Code: [ Select ]
if ($action == "upload") {
// ok, let's get the uploaded data and insert it into the db now
include "open_db.inc";
$binFile = $_FILES['binFile']['name'];
$file_size = $_FILES['binFile']['size'];
$file_temp = $_FILES['binFile']['tmp_name'];
$file_error = $_FILES['binFile']['error'];
if (isset($binFile) && $binFile != "none") {
$data = addslashes(fread(fopen($file_temp, "r"), $file_size));
$strDescription = addslashes(nl2br($txtDescription));
$sql = "INSERT INTO family_pics ";
$sql .= "(description, bin_data, filename, filesize, filetype) ";
$sql .= "VALUES ('$strDescription', '$data', ";
$sql .= "'$binFile_name', '$binFile_size', '$binFile_type')";
$result = mysql_query($sql, $db);
echo "Thank you. The new file was successfully added to our database.<br><br>";
echo "<a href='main.php'>Continue</a>";
}else
echo $file_error;
mysql_close($db);
} else {
?>
<HTML>
<BODY>
<FORM METHOD="post" ACTION="add.php" ENCTYPE="multipart/form-data">
<INPUT TYPE="hidden" NAME="MAX_FILE_SIZE" VALUE="2000000">
<INPUT TYPE="hidden" NAME="action" VALUE="upload">
<TABLE BORDER="1">
<TR>
<TD>Description: </TD>
<TD><TEXTAREA NAME="txtDescription" ROWS="10" COLS="50"></TEXTAREA></TD>
</TR>
<TR>
<TD>File: </TD>
<TD><INPUT TYPE="file" NAME="binFile"></TD>
</TR>
<TR>
<TD COLSPAN="2"><INPUT TYPE="submit" VALUE="Upload"></TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
<?php
}
?>
// ok, let's get the uploaded data and insert it into the db now
include "open_db.inc";
$binFile = $_FILES['binFile']['name'];
$file_size = $_FILES['binFile']['size'];
$file_temp = $_FILES['binFile']['tmp_name'];
$file_error = $_FILES['binFile']['error'];
if (isset($binFile) && $binFile != "none") {
$data = addslashes(fread(fopen($file_temp, "r"), $file_size));
$strDescription = addslashes(nl2br($txtDescription));
$sql = "INSERT INTO family_pics ";
$sql .= "(description, bin_data, filename, filesize, filetype) ";
$sql .= "VALUES ('$strDescription', '$data', ";
$sql .= "'$binFile_name', '$binFile_size', '$binFile_type')";
$result = mysql_query($sql, $db);
echo "Thank you. The new file was successfully added to our database.<br><br>";
echo "<a href='main.php'>Continue</a>";
}else
echo $file_error;
mysql_close($db);
} else {
?>
<HTML>
<BODY>
<FORM METHOD="post" ACTION="add.php" ENCTYPE="multipart/form-data">
<INPUT TYPE="hidden" NAME="MAX_FILE_SIZE" VALUE="2000000">
<INPUT TYPE="hidden" NAME="action" VALUE="upload">
<TABLE BORDER="1">
<TR>
<TD>Description: </TD>
<TD><TEXTAREA NAME="txtDescription" ROWS="10" COLS="50"></TEXTAREA></TD>
</TR>
<TR>
<TD>File: </TD>
<TD><INPUT TYPE="file" NAME="binFile"></TD>
</TR>
<TR>
<TD COLSPAN="2"><INPUT TYPE="submit" VALUE="Upload"></TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
<?php
}
?>
- if ($action == "upload") {
- // ok, let's get the uploaded data and insert it into the db now
- include "open_db.inc";
- $binFile = $_FILES['binFile']['name'];
- $file_size = $_FILES['binFile']['size'];
- $file_temp = $_FILES['binFile']['tmp_name'];
- $file_error = $_FILES['binFile']['error'];
- if (isset($binFile) && $binFile != "none") {
- $data = addslashes(fread(fopen($file_temp, "r"), $file_size));
- $strDescription = addslashes(nl2br($txtDescription));
- $sql = "INSERT INTO family_pics ";
- $sql .= "(description, bin_data, filename, filesize, filetype) ";
- $sql .= "VALUES ('$strDescription', '$data', ";
- $sql .= "'$binFile_name', '$binFile_size', '$binFile_type')";
- $result = mysql_query($sql, $db);
- echo "Thank you. The new file was successfully added to our database.<br><br>";
- echo "<a href='main.php'>Continue</a>";
- }else
- echo $file_error;
- mysql_close($db);
- } else {
- ?>
- <HTML>
- <BODY>
- <FORM METHOD="post" ACTION="add.php" ENCTYPE="multipart/form-data">
- <INPUT TYPE="hidden" NAME="MAX_FILE_SIZE" VALUE="2000000">
- <INPUT TYPE="hidden" NAME="action" VALUE="upload">
- <TABLE BORDER="1">
- <TR>
- <TD>Description: </TD>
- <TD><TEXTAREA NAME="txtDescription" ROWS="10" COLS="50"></TEXTAREA></TD>
- </TR>
- <TR>
- <TD>File: </TD>
- <TD><INPUT TYPE="file" NAME="binFile"></TD>
- </TR>
- <TR>
- <TD COLSPAN="2"><INPUT TYPE="submit" VALUE="Upload"></TD>
- </TR>
- </TABLE>
- </FORM>
- </BODY>
- </HTML>
- <?php
- }
- ?>
Wrap Up your Big Url | Mariana World Community
Page 1 of 1
To Reply to this topic you need to LOGIN or REGISTER. It is free.
Post Information
- Total Posts in this topic: 3 posts
- Users browsing this forum: No registered users and 172 guests
- You cannot post new topics in this forum
- You cannot reply to topics in this forum
- You cannot edit your posts in this forum
- You cannot delete your posts in this forum
- You cannot post attachments in this forum

