Файловый менеджер - Редактировать - /home2/cocinasdalloway/public_html/administrador/Home/project_detail_image_upload_pagos.php
Назад
<?php /* * Funci贸n personalizada para comprimir y * subir una imagen mediante PHP */ function compressImage($source, $destination, $quality) { // Obtenemos la informaci贸n de la imagen $imgInfo = getimagesize($source); $mime = $imgInfo['mime']; // Creamos una imagen /* switch($mime){ case 'image/jpeg': $image = imagecreatefromjpeg($source); break; case 'image/png': $image = imagecreatefrompng($source); break; case 'image/gif': $image = imagecreatefromgif($source); break; default: $image = imagecreatefromjpeg($source); } */ // Guardamos la imagen imagejpeg($image, $destination, $quality); // Devolvemos la imagen comprimida return $destination; } $delete_file = 0; if(isset($_POST['delete_file'])){ $delete_file = $_POST['delete_file']; } $ds = '/'; //1 $storeFolder = '../images/compago/'; $storeFolder1 = '../images/compago'; if (!empty($_FILES) && !isset($_POST['delete_file'])) { $tempFile = $_FILES['file']['tmp_name']; //3 $targetPath = $storeFolder.$_POST['IdProject']."/"; //4 if (!file_exists($targetPath)) { mkdir($targetPath, 0777, true); } $targetFile = $targetPath. $_FILES['file']['name']; //5 //$compressedImage=compressImage($tempFile, $targetFile, 50); if (move_uploaded_file($tempFile, $targetFile)) { $status = 'success'; $statusMsg = "El archivo se ha subido satisfactoriamente."; }else{ $statusMsg = "La compresion de la imagen ha fallado"; } //move_uploaded_file($tempFile,$targetFile); //6 echo $statusMsg; }elseif(isset($_POST['delete_file']) && $delete_file == 1){ echo $file_path = $storeFolder.$_POST['dir_file'].$_POST['target_file']; // Check if file is exists if ( file_exists($file_path) ) { // Delete the file unlink($file_path); // Be sure we deleted the file if ( !file_exists($file_path) ) { $response = array ( 'status' => 'success', 'info' => 'Successfully Deleted.' ); } else { // Check the directory's permissions $response = array ( 'status' => 'error', 'info' => 'We screwed up, the file can\'t be deleted.' ); } } else { // Something weird happend and we lost the file $response = array ( 'status' => 'error', 'info' => 'Couldn\'t find the requested file :(' ); } // Return the response echo json_encode($response); exit; }else{ $result = array(); //echo $storeFolder1; //echo $_GET['IdProject']; //echo $_GET['IdLine']; //echo $storeFolder1.$_POST['IdProject']; if($_GET['IdProject']!=''){ $files = scandir($storeFolder1."/".$_GET['IdProject']."/"); //1 if ( false!==$files ) { foreach ( $files as $file ) { if ( '.'!=$file && '..'!=$file) { //2 $obj['name'] = $file; $obj['size'] = filesize($storeFolder1."/".$_GET['IdProject']."/".$file); $result[] = $obj; } } } header('Content-type: text/json'); //3 header('Content-type: application/json'); echo json_encode($result); } } ?>
| ver. 1.4 |
Github
|
.
| PHP 8.2.22 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка