Exemplo n.º 1
0
function uploadfile($codigo, $file, $path, array $filedata)
{
    $filename = $file['file']['name'];
    $filetmpname = $file['file']['tmp_name'];
    $filetype = $file['file']['type'];
    $path = (string) $path;
    $return = array('success' => false, 'msg' => 'El archivo debe ser tipo: *.' . implode(', *.', $filedata), 'path' => $path, 'type' => $filetype, 'codigo' => $codigo);
    $filenameNew = $codigo . '-' . remp_caracter($filename);
    $destino = $path . '/' . $filenameNew;
    if (uploaldValiddate($filename, $filetype, $filedata)) {
        if (move_uploaded_file($filetmpname, $destino)) {
            $return['success'] = true;
            $return['filename'] = $filename;
            $return['filenameNew'] = $filenameNew;
            $return['path'] = $path;
            $return['msg'] = 'Tu archivo: <b>' . $filename . '</b> ha sido recibido satisfactoriamente.';
        } else {
            $return['msg'] = 'No se guardo el archivo';
        }
    }
    return $return;
}
Exemplo n.º 2
0
function uploadfile($codigo, $file, $path, array $filedata)
{
    $base_path = "{$_SERVER['DOCUMENT_ROOT']}/";
    $filename = $file["file"]["name"];
    $filetmpname = $file["file"]["tmp_name"];
    $filetype = $file["file"]["type"];
    $return = array("success" => false, "msg" => "El archivo debe ser tipo: *." . implode(", *.", $filedata), "path" => $path, "type" => $filetype, "codigo" => $codigo);
    $filenameNew = $codigo . '-' . remp_caracter($filename);
    $destino = $path . $filenameNew;
    if (substr($path, strlen($path) - 1, 1) === "/") {
        $path = substr($path, 0, strlen($path) - 1);
    }
    $S3_directory = "{$path}/{$filenameNew}";
    $S3_directory = str_replace("../", "", $S3_directory);
    $S3_directory = str_replace("//", "/", $S3_directory);
    // W("<BR>filetmpname  :::  ".$filetmpname."  FT<BR>");
    // W("<BR>destino  :::  ".$destino."   FD<BR>");
    // W("<BR>".$destino);
    if (uploaldValiddate($filename, $filedata)) {
        //PROCESO PARA EL CORTE DE UNA IMAGEN
        if (post("x1") && post("y1") && post("x2") && post("y2") && $path) {
            $x1 = (int) post("x1");
            $y1 = (int) post("y1");
            $x2 = (int) post("x2");
            $y2 = (int) post("y2");
            /* $url="{$S3_directory}";
                          $info_img=getimagesize($url);
            
                          $info_width = $info_img[0];
                          $info_height = $info_img[1];
                          $type_img = $info_img["mime"];
            
                          $src_img=imagecreatefromjpeg($url);
            
                          $src_w=$x2-$x1;
                          $src_h=$y2-$y1;
            
                          $src_x=$x1;
                          $src_y=$y1;
            
                          $dst_x=0;
                          $dst_y=0;
            
                          $dst_w=$x2-$x1;
                          $dst_h=$y2-$y1;
            
                          $dst_img=imagecreatetruecolor($dst_w,$dst_h);
            
                          imagecopyresampled(
                          $dst_img,
                          $src_img,
                          $dst_x,
                          $dst_y,
                          $src_x,
                          $src_y,
                          $dst_w,
                          $dst_h,
                          $src_w,
                          $src_h
                          );
            
                          imagejpeg($dst_img,"{$S3_directory}",100);
                          imagedestroy($src_img);
                          imagedestroy($dst_img); */
        }
        ## Subiendo los Archivos a el Servidor de Archivos S3
        if (upload_file_to_S3($filetmpname, $S3_directory)) {
            $return['success'] = true;
            $return['filename'] = $filename;
            $return['filenameNew'] = $filenameNew;
            $return["img_upload_url"] = getIconExtension($S3_directory)->bi;
            $return['msg'] = "Tu archivo: <b>{$filename}</b> ha sido recibido satisfactoriamente destino: {$S3_directory}";
        } else {
            $return['msg'] = "Ah ocurrido un error al intentar guardar el archivo {$filename} en S3 Server <br> {$S3_directory}";
        }
        if (move_uploaded_file($filetmpname, $destino)) {
        }
    }
    return $return;
}