Server IP : 162.241.126.129 / Your IP : 3.145.202.60 Web Server : Apache System : Linux 162-241-126-129.cprapid.com 4.18.0-477.27.2.el8_8.x86_64 #1 SMP Fri Sep 29 08:21:01 EDT 2023 x86_64 User : rvway5nu4 ( 1018) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/rvway5nu4/public_html/phplib/ |
Upload File : |
<?php function upload_file($db,$ValidExtns,$FieldName,$TargetDir,$OverWrite,$ImageNamePreFix){ global $PROMPT,$PROMPT_CLASS,$i_imgID,$IMG_FILE,$DirName,$UploadFile; $uploaddir = $_SERVER['DOCUMENT_ROOT'].$TargetDir."/"; $uploadfile = $uploaddir .$ImageNamePreFix.str_replace(" ","-",($_FILES["$FieldName"]['name'])); $ok = 1; if($_FILES["$FieldName"]){ $filesizebtyes = $_FILES["$FieldName"][size]; $extn=explode('.',$_FILES["$FieldName"]['name']); $extn=strtoupper($extn[(count($extn)-1)]); $FileTypesArray=explode(",",$ValidExtns); $FileName=str_replace(" ","-",($_FILES["$FieldName"]['name'])); if(!in_array($extn,$FileTypesArray)){ $ARG=array('FileName'=>"$FileName",'ValidExtns'=>"$ValidExtns"); //setPrompt($db,'NOTaValidFile',$ARG,'FILE_UPLOADER'); $PROMPT.= "NOTaValidFile"; return false; } if($filesizebtyes < 10) { $ARG=array('FileName'=>"$FileName",'ValidExtns'=>"$ValidExtns",'bytes'=>10); //setPrompt($db,'ErrorUploadingFileSizeLower',$ARG,'FILE_UPLOADER'); $PROMPT.= "ErrorUploadingFileSizeLower"; return false; } if(file_exists($uploadfile)){ $ARG=array('FileName'=>"$FileName"); if(!$OverWrite){ //setPrompt($db,'FileNameAlreadyExistsError',$ARG,'FILE_UPLOADER'); $PROMPT.= "FileNameAlreadyExistsError"; return false; }else{ //setPrompt($db,'FileNameAlreadyExists',$ARG,'FILE_UPLOADER'); $PROMPT.= "FileNameAlreadyExists"; } } if(move_uploaded_file($_FILES["$FieldName"]['tmp_name'], $uploadfile)) { @chmod($uploadfile,0777); $ARG=array('FileName'=>"$FileName"); //setPrompt($db,'FileUploaded',$ARG,'FILE_UPLOADER'); $PROMPT.= "FileUploaded"; return $UploadFile=$ImageNamePreFix.str_replace(" ","-",($_FILES["$FieldName"]['name'])); }else{ $ARG=array('FileName'=>"$FileName"); //setPrompt($db,'ProblemInUploadingFile',$ARG,'FILE_UPLOADER'); $PROMPT.= "ProblemInUploadingFile"; } }else{ $ARG=array('FileName'=>"$FileName"); //setPrompt($db,'NoFileToUpload',$ARG,'FILE_UPLOADER'); $PROMPT.= "NoFileToUpload"; } } ?>