This php script uploads (jpg) and (gif ) images into a directory, but now i want to change the file type to only (xml) files.
I need help, im confused.
I want it to upload only .xml file types. can this be customized?
SCRIPT
html;
if($_GET['do'] == 'upload')
{
//upload all the fields until done
For($i=0; $i <= $_i-1; $i++)
{
//create a random number
$_random = rand(1, 1000000);
//actual file name with the random number
$_file_name =basename($_FILES['file' . $i]['name']);
$actualfilename=basename($_FILES['file' . $i]['name']);
$type= explode('.',strrev($actualfilename));
$type= strrev("$type[0].");
$type=strtolower($type);
//file with the upload folder
$target_path = $upload_dir.$actualuser."$type";
if (in_array($type,$file_exists)) {
}
else {
echo "Invalid file format";
exit();
}
$userjpg="userdata/avatars/$actualuser".".jpg";
$usergif="userdata/avatars/$actualuser".".gif";
if ($type='.jpg' and file_exists($usergif)) {
unlink($usergif);
}
elseif ($type='.gif' and file_exists($userjpg)) {
unlink($userjpg);
}
//do not upload the 'left blank' fields
if(basename($_FILES['file' . $i]['name']) != '')
{
if(move_uploaded_file($_FILES['file' . $i]['tmp_name'], $target_path))
{
//uploaded successfuly
$_uploaded=1;
}
else
{
//error uploading
$_error=1;
}
}
else
{
$_check=$_check+1;
}
}
//file(s) did upload
if($_uploaded == '1')
{
$_uploaded=0;
echo "
Your picture has been uploaded.";
echo ("
");
}
//file uploaded?
if($_error == '1')
{
$_error=0;
echo "
There was an error uploading some of the file(s), please try again! Maybe the file size. Maximum file size is " . $_max_file_size/1000 . "KB
";
}
//user selected a file?
if($_check == $_i)
{
$_check=0;
echo "
Select a file first than click 'Upload File'
";
}
}
?>
2007-06-25
07:49:55
·
5 answers
·
asked by
Zamar
1
in
Computers & Internet
➔ Programming & Design