14 protected $uploadDirectory;
16 protected $uploadInfo;
21 public function __construct($path)
36 if(($mime == $_FILES[
'FileInput'][
'type'])&&(isset($mime)&&(!empty($mime))))
52 foreach($mime as $val)
84 die(__CLASS__.
':'.__METHOD__.
':line='.__LINE__);
93 public function path($path)
95 $this->uploadDirectory = $path;
133 return json_encode($this->status);
137 return json_encode($this->status[$respond]);
146 return $this->uploadInfo[
'newName'];
162 $this->status = array();
163 if(isset($_FILES[
"FileInput"]))
165 $UploadDirectory = $this->uploadDirectory;
176 $this->status[
'mode']=
'advanced';
177 if($this->ajax===
true)
179 $this->status[
'ajax']=
true;
180 if (!isset($_SERVER[
'HTTP_X_REQUESTED_WITH']))
182 $this->status[
'code']=
"444";
183 return $this->status;
188 $this->status[
'ajax']=
false;
192 if ($_FILES[
"FileInput"][
"size"] > $this->size)
194 $this->status[
'code']=
"413";
195 return $this->status;
199 if(in_array(strtolower($_FILES[
'FileInput'][
'type']),$this->mime)===
true)
201 $this->status[
'mime']=$_FILES[
'FileInput'][
'type'];
205 $this->status[
'code']=
"415-0";
206 return $this->status;
211 $this->status[
'mode']=
'simple';
214 $File_Name = strtolower($_FILES[
'FileInput'][
'name']);
215 $File_Ext = substr($File_Name, strrpos($File_Name,
'.'));
216 $Random_Number = rand(0, 9999999999).date(
'YmdHis');
217 $NewFileName = $Random_Number.$File_Ext;
219 $this->uploadInfo = array(
'oldName'=>$File_Name,
221 'rnd'=>$Random_Number,
222 'newName'=>$NewFileName);
223 $this->status[
'info'] = $this->uploadInfo;
225 if(!is_dir($UploadDirectory))
227 mkdir($UploadDirectory,0777);
229 if(move_uploaded_file($_FILES[
'FileInput'][
'tmp_name'], $UploadDirectory.$NewFileName))
232 $this->status[
'code']=
"200";
233 $this->status[
'name']=$NewFileName;
234 $this->status[
'path']=$UploadDirectory;
238 $this->status[
'code']=
"417";
244 $this->status[
'code']=
"404";
247 return $this->status;