HEX
Server: Apache
System: Linux 185.122.168.184.host.secureserver.net 5.14.0-570.52.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Oct 15 06:39:08 EDT 2025 x86_64
User: barbeatleanalyti (1024)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: /home/barbeatleanalyti/public_html/api.beatleanalytics.com/corporate/live/upload_image.php
<?php
/*
 * Following code will get single department details
 * A industry is identified by dept_id
 */
 
// array for JSON response
$response = array();
 
// include db connect class
require_once 'db_connect.php';
 
// connecting to db
$db = new DB_CONNECT();

 //Getting the server ip 
 $server_ip = gethostbyname(gethostname());

  //this is our upload folder 
 $upload_path = 'webprofileimages/';
 
  //creating the upload url 
 $upload_url = 'http://localhost/owner.beatleanalytics.com/documents/local/'.$upload_path; 
 
 // echo $_SERVER['DOCUMENT_ROOT'] ;
 if($_SERVER['REQUEST_METHOD']=='POST'){
	 
	//checking the required parameters from the request 
	if(isset($_POST['name']) and isset($_FILES['image']['name']) and isset($_POST['name'])){
	 
		//getting name from the request 
		 $name = $_POST['name'];
		 $id = $_POST['id'];
		 
		 //getting file info from the request 
		 $fileinfo = pathinfo($_FILES['image']['name']);
		 
		 //getting the file extension 
		 $extension = $fileinfo['extension'];
		 
		 //file url to store in the database 
		 $file_url = $upload_url . getFileName() . '.' . $extension;
		 
		 //file path to upload in the server 
		 $file_path = $upload_path . getFileName() . '.'. $extension; 
		  //trying to save the file in the directory 
		 
		 try{
			 //saving the file 
			 move_uploaded_file($_FILES['image']['tmp_name'],$upload_url);
			 $sql = "UPDATE beatle_userlogin SET webprofileimage = '$name' where userId = '$id' ;";
		 
		 //adding the path and name to database 
		 if(mysql_query($sql)){
		 
			 //filling response array with values 
			 $response['error'] = false; 
			 $response['url'] = $file_url; 
			 $response['name'] = $name;
		 }
		 //if some error occurred 
		 }catch(Exception $e){
			 $response['error']=true;
			 $response['message']=$e->getMessage();
		 } 
		 //displaying the response 
		 echo json_encode($response);
	}else{
	 $response['error']=true;
	 $response['message']='Please choose a file';
	}
 }
  /*
 We are generating the file name 
 so this method will return a file name for the image to be upload 
 */
 function getFileName(){
	
	 // $sql = "SELECT max(id) as id FROM images";
	 // $result = mysql_fetch_array(mysql_query($sql));
	 
	 // if($result['id']==null)
	 // return 1; 
	 // else 
	 // return ++$result['id']; 
	return 121;
 }
 
?>