Hi. I've written this script that works fine with register_globals = On in my php.ini configuration. I use windows 2003 server(for training purposes, normally a Fedora user...) with IIS and PHP 4.3.xx.
I've tried to make a similar script that works with register_globals = Off, but I can't seem to get it to work. This is the (working) script with register_globals = Off:
if($upload){
if($file= addslashes(fread(fopen($data, "rb"), filesize($data)))){
write_file($data, $file);
header("Location: tradefiles.php?user=".$_SESSION['user']."");
}else echo "shit";
}
function write_file($data, $file){
$raw = fread(fopen($data, "r"), filesize($data));
$fs = filesize($data);
$file_dir = ".";
$file_url = "http://vs2003.hive.no/";
echo "Denne filen ble lastet opp til serveren vår:<br>";
foreach( $_FILES as $file_name => $file_array ) {
print "path: ".$file_array['tmp_name']."<br>\n";
print "name: ".$file_array['name']."<br>\n";
print "type: ".$file_array['type']."<br>\n";
print "size ".$file_array['size']."<br>\n";
move_uploaded_file( $file_array['tmp_name'], $file_dir.'/'.$file_array['name'] )
or die ("Couldn't Copy");
}
if (!$handle = fopen($file_array['name'], 'w+')) {
print "Cannot open file (".$file_array['name'].")";
exit;
}
if (!fwrite($handle, $raw)) {
print "Cannot write to file (".$file_array['name'].")";
exit;
}
fclose($handle);
}
I've tried changing $data/$file to $FILE, $HTTP_POST_FILES, $POST['data'] but I get an error message saying "undefined index: data" or something like that...
...I've been working on this for a while and I've looked at a lot of differen scripts around the net, but can't seem to find the right solution.
Help would be much appreciated as this is the only script I can't get to work with register_globals = Off(and I would Really Like to turn register_globals OFF).
cassius