ho trovato uno script buono xò ho un problema ... non mi uploada le immagini....
questo è il codice della pagina:
Codice PHP:
<?php
include ('protect.php');
//edit this
$_max_file_size = '1000000'; //file size in bytes.
$upload_dir = "userdata/avatars/"; //upload folder..chmod to 777
$_i = "1"; //number of files to upload at one time
$file_exists= array('.jpg','.gif');
//end edit
echo <<<html
<body bgcolor="#EBEBEB">
<p align="center">[b]<font size="5" color="#FF0000">[i]Picture Manager[/i]</font>[/b]</p>
<div align="center">
<table border="1" width="40%" cellspacing="0" cellpadding="0" height="107" bgcolor="#D1D1D1">
<tr>
<td width="100%" height="95" valign="middle">
html;
echo "[b]<font size='1'>Maximum file size : " . $_max_file_size/1000 . "KB</font>
";
echo "<form enctype='multipart/form-data' action='?do=upload' method='post'>";
echo "<input type='hidden' name='MAX_FILE_SIZE' value='" . $_max_file_size , "'>";
echo "<font color='#FF0000'><center>Please select a display picture:
";
//show number of files to select
For($i=0; $i <= $_i-1;$i++)
{
echo "<input name='file" . $i . "' type='file'>";
}
echo "<input type='submit' value='Upload File'></center></font>";
echo "</form>[/b]<p align='center'>[b]<font size='3' color='#FF0000'>[url='main.php']Home[/url]</font>[/b]</p>";
echo <<<html
</td>
</tr>
</table>
</div></body>
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 "[b]<center>Your picture has been uploaded.</center>[/b]";
echo ("<META HTTP-EQUIV=Refresh CONTENT=\"3; URL=main.php\">");
}
//file uploaded?
if($_error == '1')
{
$_error=0;
echo "[b]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
[/b]";
}
//user selected a file?
if($_check == $_i)
{
$_check=0;
echo "[b]Select a file first than click 'Upload File'
[/b]";
}
}
?>
<p align="center">[b]© 2006 Ahsan Mahmood. [url="http://energon.ueuo.com"]Energon[/url][/b]</p>