Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if( ! is_uploaded_file( $_FILES['imageUpload']['tmp_name']) || $_FILES['imageUpload']['error'] !== UPLOAD_ERR_OK) {
- echo "<p class='alert alert-danger text-danger font-size-16'>Selecione uma image para enviar.</p>";
- exit();
- }
- $maxFileSize = 5242880;
- if($_FILES['imageUpload']['size'] > $maxFileSize) {
- echo "<p class="alert alert-danger text-danger font-size-16">Tamanho de arquivo maior do que o permitido.</p>";
- exit();
- }
- ##############################################
- if(is_array(getimagesize($_FILES["imageUpload"]["tmp_name"]))){
- $image_type_check = 'true';
- } else {
- $image_type_check = 'false';
- }
- if($image_type_check == 'false') {
- echo "<p class="alert alert-danger text-danger font-size-16">Formato de arquivo não permitido.</p>";
- exit();
- }
- $filename = $_FILES['imageUpload']['name'];
- $location = "../arquivos/";
- $imagename = $_FILES['imageUpload']['name'];
- $source = $_FILES['imageUpload']['tmp_name'];
- $ext = explode( ".", $imagename );
- $ext = end( $ext );
- $nN = md5( $filename );
- $nN = time() . $nN;
- $novo_nome = $nN . "." . $ext;
- $target = $location . $novo_nome;
- $image_info = getimagesize($_FILES["imageUpload"]["tmp_name"]);
- $image_width = $image_info[0];
- $image_height = $image_info[1];
- if($image_width>800) {
- move_uploaded_file($source, $target);
- $imagepath = $novo_nome;
- $save = $location . $imagepath;
- $file = $location . $imagepath;
- list($width, $height) = getimagesize($file) ;
- $modwidth = 800;
- $diff = $width / $modwidth;
- $modheight = $height / $diff;
- $tn = imagecreatetruecolor($modwidth, $modheight) ;
- $image = imagecreatefromjpeg($file) ;
- imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
- imagejpeg($tn, $save, 72);
- } else if($image_width<800) {
- move_uploaded_file( $source, $target );
- $imagepath = $novo_nome;
- $save = $location . $imagepath;
- $file = $location . $imagepath;
- list($width, $height) = getimagesize($file) ;
- $modwidth = $image_width;
- $diff = $width / $modwidth;
- $modheight = $height / $diff;
- $tn = imagecreatetruecolor($modwidth, $modheight) ;
- $image = imagecreatefromjpeg($file) ;
- imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
- imagejpeg($tn, $save, 72);
- }
- Array
- (
- [0] => nota-12809312-001.jpg
- [1] => nota-74831223-004.png
- [2] =>
- [3] =>
- [4] =>
- [5] =>
- [6] =>
- [7] =>
- [8] =>
- [9] =>
- [10] =>
- [11] =>
- )
- $count = count( $_FILES['imageUpload']['name'] );
- if( $count == 0 ) {
- echo "<p class="alert alert-danger text-danger font-size-16">Selecione uma imagem para o anúncio.</p>";
- exit();
- }
- #### UPLOAD DAS IMAGENS
- $maxFileSize = 5242880;
- $imgError = 0;
- $imgErrorFile = array();
- $uploadSuccess = 0;
- for( $x=1;$x<=$count;$x++ ) {
- if(is_array(getimagesize($_FILES["imageUpload"]["tmp_name"][$x]))){
- $image_type_check = 'true';
- } else {
- $image_type_check = 'false';
- }
- if($image_type_check == 'false') {
- echo "<p class="alert alert-danger text-danger font-size-16">Formato de arquivo não permitido.</p>";
- exit();
- }
- if( $_FILES['imageUpload']['size'][$x] > $maxFileSize ) {
- echo "<p class="alert alert-danger text-danger font-size-16">Tamanho de arquivo maior do que o permitido.</p>";
- exit();
- }
- $count = count( $_FILES['imageUpload']['name'] );
- if( $count == 0 ) {
- echo "<p class="alert alert-danger text-danger font-size-16">Selecione uma imagem para o anúncio.</p>";
- exit();
- }
- $maxFileSize = 5242880;
- for( $x=0;$x<$count;$x++ ) {
- if(is_array(getimagesize($_FILES["imageUpload"]["tmp_name"][$x]))){
- $image_type_check = 'true';
- } else {
- $image_type_check = 'false';
- }
- if($image_type_check == 'false') {
- echo "<p class="alert alert-danger text-danger font-size-16">Formato de arquivo não permitido.</p>";
- exit();
- }
- if( $_FILES['imageUpload']['size'][$x] > $maxFileSize ) {
- echo "<p class="alert alert-danger text-danger font-size-16">Tamanho de arquivo maior do que o permitido.</p>";
- exit();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement