0byt3m1n1
Path:
C:
/
wamp64
/
www
/
cpms_new
/
model
/
[
Home
]
File: uploader_mdl.php
<?php require_once "../lib/config.php"; require_once "filecheck_mdl.php"; class Upload { //5 public function uploadDoccument($table_name,$table_id,$type,$original_file_name,$temp_filepath) { //8 $result_array=array(); $result_array['flag']=""; $result_array['filename']=""; $result_array['file_error']=""; if($type=="application/msword" || $type=="application/vnd.openxmlformats-officedocument.wordprocessingml.document" || $type=="application/pdf" || $type=="application/rtf"|| $type=="application/vnd.ms-powerpoint" || $type=="application/mspowerpoint " || $type=="text/plain" || $type=="application/zip" || $type=="application/vnd.openxmlformats-officedocument.presentationml.slideshow" || $type=="image/jpeg"||$arr_img_type[$type]=="bmp" || $arr_img_type[$type]=="gif" || $arr_img_type[$type]=="jpeg" || $arr_img_type[$type]=="png") { // 14 $document_url= "../Proposels/".$table_id.$original_file_name; $result= Filecheck::doccumentCheck("addproject","projectproposel", $table_id.$original_file_name); ///// prjctstaf_tbl if($result==false) { //22 $error_flag=0; } //22 else // file exists in prjctstaf_tbl { //22 $error_flag=1; $error['file_format']="File name already exists. Please rename the file and try again"; } //22 // check in file shelf $result= Filecheck::doccumentCheck("fileshelf","fileupload", $table_id.$original_file_name); ///// file shelf_tbl if($result==false) { //22 $error_flag=0; } //22 else // file exists in file shelf_tbl { //22 $error_flag=1; $error['file_format']="File name already exists. Please rename the file and try again"; } //22 // check in employe table $result= Filecheck::doccumentCheck("employe","photo", $table_id.$original_file_name); ///// employe_tbl if($result==false) { //22 $error_flag=0; } //22 else // file exists in employe_tbl { //22 $error_flag=1; $error['file_format']="File name already exists. Please rename the file and try again"; } //22 // check in student table $result= Filecheck::doccumentCheck("student","file", $table_id.$original_file_name); ///// employe_tbl if($result==false) { //22 $error_flag=0; } //22 else // file exists in employe_tbl { //22 $error_flag=1; $error['file_format']="File name already exists. Please rename the file and try again"; } //22 ////// } // 14 else { // 14 $error_flag=1; $error['file_format']="Invalid file format"; } //14 if($error_flag==0) { // 67 if( !move_uploaded_file($temp_filepath,$document_url) ) { $error_flag=1; $error['file_format']="file not uploaded"; } else { $error_flag=0; } }// 67 $result_array['flag']=$error_flag; $result_array['filename']=$table_id.$original_file_name; $result_array['file_error']=$error['file_format']; return $result_array; } //8 ////////////////////////////Only for photo/////// public function uploadPhoto($table_name,$table_id,$type,$original_file_name,$temp_filepath) { //88 $result_array=array(); $result_array['flag']=""; $result_array['filename']=""; $result_array['file_error']=""; if($type=="image/jpeg"||$arr_img_type[$type]=="bmp" || $arr_img_type[$type]=="gif" || $arr_img_type[$type]=="jpeg" || $arr_img_type[$type]=="png") { // 14 $document_url= "../Proposels/".$table_id.$original_file_name; $result= Filecheck::doccumentCheck("addproject","projectproposel", $table_id.$original_file_name); ///// prjctstaf_tbl if($result==false) { //22 $error_flag=0; } //22 else // file exists in prjctstaf_tbl { //22 $error_flag=1; $error['file_format']="File name already exists. Please rename the file and try again"; } //22 // check in file shelf $result= Filecheck::doccumentCheck("fileshelf","fileupload", $table_id.$original_file_name); ///// file shelf_tbl if($result==false) { //22 $error_flag=0; } //22 else // file exists in file shelf_tbl { //22 $error_flag=1; $error['file_format']="File name already exists. Please rename the file and try again"; } //22 // check in employe table $result= Filecheck::doccumentCheck("employe","photo", $table_id.$original_file_name); ///// employe_tbl if($result==false) { //22 $error_flag=0; } //22 else // file exists in employe_tbl { //22 $error_flag=1; $error['file_format']="File name already exists. Please rename the file and try again"; } //22 // check in student table $result= Filecheck::doccumentCheck("student","file", $table_id.$original_file_name); ///// employe_tbl if($result==false) { //22 $error_flag=0; } //22 else // file exists in employe_tbl { //22 $error_flag=1; $error['file_format']="File name already exists. Please rename the file and try again"; } //22 ////// } // 14 else { // 14 $error_flag=1; $error['file_format']="Invalid file format"; } //14 if($error_flag==0) { // 67 if( !move_uploaded_file($temp_filepath,$document_url) ) { $error_flag=1; $error['file_format']="file not uploaded"; } else { $error_flag=0; } }// 67 $result_array['flag']=$error_flag; $result_array['filename']=$table_id.$original_file_name; $result_array['file_error']=$error['file_format']; return $result_array; } //88 } //5 ?>