file upload

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In the following snippet, which uploads binary files to a mySQL database it
works fine when Register Globals are set to ON.
.................
mysql_connect("localhost","root","pass");
mysql_select_db("adatabase");

$data = addslashes(fread(fopen($form_data, "r"), filesize($form_data)));

$result=mysql_query("INSERT INTO binary_data
(description,bin_data,filename,filesize,filetype) ".
"VALUES
('$form_description','$data','$form_data_name','$form_data_size','$form_data
_type')");

$id= mysql_insert_id();
print "<p>This file has the following Database ID: <b>$id</b>";
echo "<br>";
echo "<a href=\"getdata.php?id=$id\">Click to view file</a>";

mysql_close();
...................

However, when I turn the Register Globals to OFF and insert a $_FILES[ ][ ]
array for the form variables such as:

-----------------

$data = addslashes(fread(fopen($_FILES[form_data], "r"),
filesize($_FILES[form_data])));

and

"VALUES
('$_FILES[form_data][form_description]','$_FILES[form_data][data]','$_FILES[
form_data][form_data_name]','$_FILES[form_data][form_data_size]','$_FILES[fo
rm_data][form_data_type]')");
-----------------

The file does not get uploaded.

Any assiatnce will be greatly appreciated.
Thank you.
TR

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux