با سلام :
دوستان میشه بگید چه جوری خاصیت Overwrite رو به این کد اضافه کنم ؟
دوستان میشه بگید چه جوری خاصیت Overwrite رو به این کد اضافه کنم ؟
PHP:
<?php
echo '<form method="post" enctype="multipart/form-data" action="'.$_SERVER['PHP_SELF'].'">';
echo '<input type="file" name="userfile">';
echo '<input type="submit" value="upload">';
echo '</form>';
$path = './' ;
$max_size = 200000;
if(isset($HTTP_POST_FILES['userfile']))
{
if(is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name']))
{
if($HTTP_POST_FILES['userfile']['size'] < $max_size)
{
if(!file_exists($path . $HTTP_POST_FILES['userfile']['name']))
{
if(@rename($HTTP_POST_FILES['userfile']['tmp_name'],$path.$HTTP_POST_FILES['userfile']['name']))
{
$html_output = 'Upload sucessful!<br>';
$html_output .= 'File Name: '.$HTTP_POST_FILES['userfile']['name'].'<br>';
$html_output .= 'File Size: '.$HTTP_POST_FILES['userfile']['size'].' bytes<br>';
$html_output .= 'File Type: '.$HTTP_POST_FILES['userfile']['type'].'<br>';
$image = $HTTP_POST_FILES['userfile']['name'] ;
}else{
$html_output = 'Upload Failed !<br>';
if(!is_writeable($path))
{
$html_output = 'The Directory "'.$path.'" Must Be Writeable!<br>';
}else{
$html_output = 'An Unknown Error Ocurred .<br>';
}
}
}else{
$html_output = 'The File Already Exists<br>';
}
}
else{
$html_output = 'Wrong file type<br>';
}
}else{
$html_output = 'The file is too big<br>';
}
}
echo @$html_output;
?>