Sākumlapa › Forumi › Mājas lapu izstrāde › Servera puse (php, java, ruby, perl, python) › upload error ajax file upload
Kas šitajā kodā nav pareizi ?
Kā foto virs 2mb tā iemer kļūduupload error !
‘.$locale[156].’‘;
$img = false;
if(isset($_GET[’file’])) {
if(!strpos($_GET[’file’], ‘.’)){
$_GET[’file’] = base64_decode($_GET[’file’]);
}
}
if (!empty($_FILES))
{
$tempFile = $_FILES[’Filedata’][’tmp_name’];
$targetPath = FULLPATH . ‘uploads/temp/’;
if(!isset($_POST[’field_id’])) $_POST[’field_id’] = “”;
if(!isset($_POST[’form_id’])) $_POST[’fielform_id_id’] = “”;
$field_id = $_POST[’field_id’];
$form_id = $_POST[’form_id’];
if(!is_numeric($field_id)){die(’field error’.$back);}
$form_id = str_replace(’/’, ”, $form_id);
$form_id = str_replace(’\’, ”, $form_id);
$form_id = str_replace(’,’, ”, $form_id);
include(COREPATH.’fields.php’);
$field = $fields[’f_’.$field_id];
if(isset($_FILES[’Filedata’][’error’]))
{
if($_FILES[’Filedata’][’error’] == 1){die(’upload error #1’);}
if($_FILES[’Filedata’][’error’] == 2){die(’upload error #2’);}
if($_FILES[’Filedata’][’error’] == 3){die(’upload error #3’);}
}
//pr($_FILES[’Filedata’][’tmp_name’]);
if(!file_exists($_FILES[’Filedata’][’tmp_name’]))
{
die(’file doesn’t exists’.$back);
}
if(file_exists($_FILES[’Filedata’][’tmp_name’]))
{
$ext = get_ext($_FILES[’Filedata’][’name’]);
if(!in_array($ext, $field[’values_array’]) && count($field[’values_array’]) > 0)
{
die(’Запрещённый
файл’.$back);
}
else
{
if(is_numeric($field[’max’]) && (filesize($_FILES[’Filedata’][’tmp_name’]) > ($field[’max’] * 1024)))
{
die(’Превышен
размер’.$back);
}
}
}
$filename = $form_id.’-‘.$field_id.’.’.$ext;
if(substr($ext, 0, 3) == ‘php’){exit();}
$targetFile = str_replace(’//’,’/’,$targetPath) . $filename;
// $fileTypes = str_replace(’*.’,”,$_REQUEST[’fileext’]);
// $fileTypes = str_replace(’;’,’|’,$fileTypes);
// $typesArray = split(’|’,$fileTypes);
// $fileParts = pathinfo($_FILES[’Filedata’][’name’]);
// if (in_array($fileParts[’extension’],$typesArray)) {
// Uncomment the following line if you want to make the directory if it doesn’t exist
// mkdir(str_replace(’//’,’/’,$targetPath), 0755, true);
if(move_uploaded_file($tempFile,$targetFile))
{
if($field[’type’] == ‘f’)
{
$img = $settings[’path’].’images/ico/’.get_ico($ext).’?’.rand(100000, 999999);
}
else
{
$img = $settings[’path’].’gettmpfile/?file=’.$filename.’&rand=’.rand(100000, 999999);
}
}
else
{
die(’error file upload’.$back);
}
if($img){
header(”Location: “.PATH.”ajaxfileupload_f/?field_key=f_”.$field[’id’].”&file=”.base64_encode($img));
}
}
if(!isset($field_id)){
$field_id = substr($_GET[’field_key’], 2);
}
echo “
“.$locale[85].”: “;
if(count($field[’values_array’]) > 0){
echo implode(’, ‘, $field[’values_array’]);
}
echo “
“;
exit();
?>
Zem 2mb ielādējās bilde .
Max pieejamos settingos adminpaneli visu saliku uz max bet nelādē kas lielākas par 2mb
Un pats kļūdas paziņojums arī nenāktu par sliktu.
phpinfo();
tad arī neredz?
Man rāda šādi
max_file_uploads Local Values-20 Master Value-20
post_max_size 8M 8M
upload_max_filesize 2M 2M
memory_limit 128M
Te arī ir problēma ja ?
Paldies visiem kas palīdzēja
Preses relīzes