Hi all,
I have a PHP upload file script that use to work, but is no longer working and I can't figure out why. It was working as of yesterday, and the only thing I did was install Open CRM last night. I did a manual install, so it shouldn't have reconfigured the HTTPD.conf or PHP.ini files.
Here's the environment:
PHP 4.0.2
RedHat 6.2
Linux 2.2.14-5.0
Apache 1.3.6
I put some echo statements in the code and it appears that the following global variables are being set:
$PHP_SELF
$userfile_name
But the following globals are not being set:
$WINDIR
$userfile_size
$userfile
Does anyone know what could be causing this weird behavior?
Thanks, HH
==============================================
<?
// file_upload.php
$archive_dir = "./docs";
function upload_form()
{
global $PHP_SELF;
?>
<FORM METHOD="POST" ENCTYPE="MULTIPART/FORM-DATA"
ACTION="<? echo $PHP_SELF ?>">
<INPUT TYPE="HIDDEN" NAME="form" VALUE="upload" >
Upload a list file:
<INPUT TYPE="FILE" NAME="userfile" SIZE "100">
<INPUT TYPE="SUBMIT" NAME="SUBMIT" VALUE= "Upload">
</FORM>
<?
}
function upload_file()
{
global $userfile, $userfile_name, $userfile_size,
$userfile_type, $archive_dir, $WINDIR;
// Testing if we can access the filesystem.
if(isset($WINDIR))
$userfile = str_replace("\\\\","\\",$userfile);
$filename = basename($userfile_name);
if($userfile_size <= 0 )
die ("filename is empty.");
if(!copy($userfile, "/usr/local/upload/".$filename ))
die("Can't copy $userfile_name to $filename.");
echo "$filename has been successfully uploaded.<BR><BR>";
}
if ($form == "newlist")
upload_form();
if ($form == "upload" )
upload_file();
?>
==============================================