Forum Moderators: coopster

Message Too Old, No Replies

File Upload Register Globals Off

         

EightN9ne

12:13 am on May 1, 2007 (gmt 0)

10+ Year Member



My coding was all done when my host had register globals on but they have now changed it to off. I have managed to change over most of the forms but I am having trouble with file uploads. I have spent hours trying to figure it out with no luck so any help is appreciated.

Here is the code when register globas was on

Upload Form:

<form method="post" action="iceschedupload.php" enctype="multipart/form-data">

<input type="hidden" name="action" value="upload">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td><p class="headline"> File:</p> </td>
<td><input type="file" name="binFile"></td>
</tr>
<tr align="center">
<td COLSPAN="2"><br>
<input type="submit" value="Upload">
</td>
</tr>
</table>
</form>

upload script (iceschedupload.php):

if ($action == "upload") {
include("dbinfo.inc.php");
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

if (isset($binFile) && $binFile!= "none") {
$data = addslashes(fread(fopen($binFile, "r"), filesize($binFile)));
$strDescription = addslashes(nl2br($txtDescription));
$query = "INSERT INTO icesched VALUES (NULL,'$binFile_name','$binFile_size','$binFile_type','$data')";
mysql_query($query);
echo "<p class=normal>Thank you. The new file was successfully added to our database.</p><br><br>";
}
mysql_close();

} else {}

I have tried changing all of the values to be inserted to $_POST[variable here] but that didnt work. Can someone please help me!

Thank you

eelixduppy

12:17 am on May 1, 2007 (gmt 0)



Hello, and Welcome to WebmasterWorld!

File upload information can be found within the $_FILES [php.net] superglobal. You are going to have to go through your code and replace your variables with the appropriate

$_FILES
array elements. There is more information regarding file uploads at php.net: [php.net...]

Good luck! :)

EightN9ne

10:05 pm on May 2, 2007 (gmt 0)

10+ Year Member



Thank you I got it working now!