REGISTER GLOBALS=off: Variable Handling
Posted: Tue May 06, 2003 1:06 pm
Help please. I am running a streaming audio server and I need people with a certain user and pass to be able to upload via their browser.
I have the form built and actually tested this on a server with Register Globals on. Everything worked great but, the server I am hosting on has Register Globals off. As a result I have had a heck of a time passing the variables to the page which does the upload. I have read just about everything I can find as far as documentation and have not had any success. Below I have attached the code from both the upload form and the action page. I have tried different methods so you may see some differences. I hope someone can help.
Forgot to add this.
Here is the error I get:string(86) "C:\\Documents and Settings\\jsteidinger\\Desktop\\TEST_UPLOAD_Breaking_Bread_112402.rm"
string(0) ""
string(0) "" Couldn't copy the file.
I have tried both large and small files.
Upload form:
<?
echo '<HTML><HEAD><TITLE>Upload a File</TITLE></HEAD>';
echo '<BODY leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">';
echo '<br><br>';
echo '<table border="2" bordercolor="#000000">';
echo '<tr><td>';
echo '<table align="left" border="0" bgcolor="#CCCCCC"><tr>';
echo '<td><strong><font face="Verdana, Arial, Helvetica, sans-serif" size="1">File to Upload:</font></strong></td></tr>';
echo '<FORM METHOD="GET" ACTION="do_upload2.php" ENCTYPE="multipart/form-data" target="_blank">';
echo '<tr><td><INPUT TYPE="file" NAME="img1" SIZE="25"></td></tr>';
echo '<tr><td><INPUT TYPE="submit" NAME="submit" VALUE="Send File"></td></tr>';
echo '</FORM></table></td></tr></table>';
echo '</BODY></HTML>';
?>
Here is the Action Page:
<?
import_request_variables("G", "up_");
var_dump("$up_img1");
echo '<br>';
var_dump("$up_img1_name");
echo '<br>';
var_dump("$up_img1_size");
if ($up_img1 != "") {
copy("$up_img1", "http://www.lallygag.net/~justin/media/r ... _img1_name")
or die("Couldn't copy the file.");
} else {
die("No input file specified");
}
?>
<HTML>
<HEAD>
<TITLE>Successful File Upload</TITLE>
</HEAD>
<BODY>
<font size="1" face="Verdana, Arial, Helvetica, sans-serif">File has been uploaded
successfully! </font>
<P><font size="1" face="Verdana, Arial, Helvetica, sans-serif">You sent: </font>
<font face="Verdana, Arial, Helvetica, sans-serif" size="1">
<? echo "$up_img1"; ?>
, a</font> <font size="1" face="Verdana, Arial, Helvetica, sans-serif">
<? echo "$_GET['img1_size']"; ?>
byte file with a mime type of
<? echo "$_GET['img1_type']"; ?>
.</font></P>
<font size="1" face="Verdana, Arial, Helvetica, sans-serif"><a href="javascript:history.go(-1)">Click
Here to upload another file. </a></font>
</BODY>
</HTML>
Hope someone can help...
I have the form built and actually tested this on a server with Register Globals on. Everything worked great but, the server I am hosting on has Register Globals off. As a result I have had a heck of a time passing the variables to the page which does the upload. I have read just about everything I can find as far as documentation and have not had any success. Below I have attached the code from both the upload form and the action page. I have tried different methods so you may see some differences. I hope someone can help.
Forgot to add this.
Here is the error I get:string(86) "C:\\Documents and Settings\\jsteidinger\\Desktop\\TEST_UPLOAD_Breaking_Bread_112402.rm"
string(0) ""
string(0) "" Couldn't copy the file.
I have tried both large and small files.
Upload form:
<?
echo '<HTML><HEAD><TITLE>Upload a File</TITLE></HEAD>';
echo '<BODY leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">';
echo '<br><br>';
echo '<table border="2" bordercolor="#000000">';
echo '<tr><td>';
echo '<table align="left" border="0" bgcolor="#CCCCCC"><tr>';
echo '<td><strong><font face="Verdana, Arial, Helvetica, sans-serif" size="1">File to Upload:</font></strong></td></tr>';
echo '<FORM METHOD="GET" ACTION="do_upload2.php" ENCTYPE="multipart/form-data" target="_blank">';
echo '<tr><td><INPUT TYPE="file" NAME="img1" SIZE="25"></td></tr>';
echo '<tr><td><INPUT TYPE="submit" NAME="submit" VALUE="Send File"></td></tr>';
echo '</FORM></table></td></tr></table>';
echo '</BODY></HTML>';
?>
Here is the Action Page:
<?
import_request_variables("G", "up_");
var_dump("$up_img1");
echo '<br>';
var_dump("$up_img1_name");
echo '<br>';
var_dump("$up_img1_size");
if ($up_img1 != "") {
copy("$up_img1", "http://www.lallygag.net/~justin/media/r ... _img1_name")
or die("Couldn't copy the file.");
} else {
die("No input file specified");
}
?>
<HTML>
<HEAD>
<TITLE>Successful File Upload</TITLE>
</HEAD>
<BODY>
<font size="1" face="Verdana, Arial, Helvetica, sans-serif">File has been uploaded
successfully! </font>
<P><font size="1" face="Verdana, Arial, Helvetica, sans-serif">You sent: </font>
<font face="Verdana, Arial, Helvetica, sans-serif" size="1">
<? echo "$up_img1"; ?>
, a</font> <font size="1" face="Verdana, Arial, Helvetica, sans-serif">
<? echo "$_GET['img1_size']"; ?>
byte file with a mime type of
<? echo "$_GET['img1_type']"; ?>
.</font></P>
<font size="1" face="Verdana, Arial, Helvetica, sans-serif"><a href="javascript:history.go(-1)">Click
Here to upload another file. </a></font>
</BODY>
</HTML>
Hope someone can help...