1

Estoy creando una web con conexión a base de datos en godaddy. Al tratar de subir archivos relativamente grandes (4MB o más) a una carpeta al servidor me dice el explorador que la conexión ha sido reiniciada ¿a qué se debbe? pd: soy turboprincipiante

<?php ob_start();

include('conection.php');

$a = rand(1,100);
$b = rand(1,100);
$c = rand(1,100);

if(isset($_SESSION['user_name']))
{

    $user = $_SESSION['user_name'];
    $user_id = $_SESSION['id'];
    $total = "file".$user.$a.$b.$c;
    $file_name = isset($_FILES['file']['name']);

    if(isset($_FILES['file']['tmp_name'])) $path = $_FILES['file']['tmp_name'];

    else $path = null;

        if(is_uploaded_file($path))
        { 
            if($_FILES['file']['type'] == 'image/png' OR $_FILES['file']['type'] == 'image/gif' OR $_FILES['file']['type'] == 'image/jpeg' )
            {
                $extension = 'jpg';
                $type = array('image/jpeg' => 'jpg');
                $name = $user_id. $total.'.'.$extension;
                $destination =  "images/".$name;
                copy($path, $destination);
                $path_image = $destination;
                $max_x = 600;
                $max_y = 800;
                $size = getimagesize($path_image);
                $image_x = $size[0];
                $image_y = $size[1];
                $image_type = $size['mime'];

                switch ( $image_type )
                {
                    case "image/jpg":
                    case "image/jpeg":
                        $image = imagecreatefromjpeg( $path_image );
                        break;
                    case "image/png":
                        $image = imagecreatefrompng( $path_image );
                        break;
                    case "image/gif":
                        $image = imagecreatefromgif( $path_image );
                        break;
                }//End switch

                $panel = imagecreatetruecolor( $max_x, $max_y );
                imagecopyresampled($panel, $image, 0, 0, 0, 0, $max_x, $max_y, $image_x, $image_y);
                imagejpeg($panel, $destination, 80);
            }//en if($_FILES['foto1']['type'] ==...

            elseif($_FILES['file']['type']= "aplication/pdf")
            {
                $extension = 'pdf';
                $name = $id. $total.'.'.$extension;
                $destination =  "files/".$name;
                copy($path, $destination);
                $path_image = $destination;
            }
            else {$destination = null;}

        }//End if(is_uploaded_file(

ob_end_flush() ?>

<meta charset="UTF-8"/>

<div id="posting">
    <form class="transparent-box" action="<?php ob_start(); echo $_SERVER['PHP_SELF']; ob_end_flush() ?>" method="post"  enctype="multipart/form-data">
        <textarea class="input-field" name="text" id="textarea" type="text" maxlenght = "140" rows="2" columns="70" placeholder=""/></textarea>
        <input type="file" id="filebutton" name="file" class="input-button"/>
        <select name="category" class="input-button">
            <option value="0">Sin categoria</option>            
            <option value="1">Opción 1</option>
            <option value="2">Opción 2</option>
            <option value="3">Opción 3</option>
        </select>
        <input type="submit" name="send" class="input-button" value="Publicar " />
    </form>
</div>

<?php ob_start();    

        if(isset($_POST['send']))
        {
            if(empty($_POST['text']))
            { 
                echo "<script>alert('Campo de texto vacío.')</script>";
            }//end if(empty
            else
            {
                $con = new mysqli("localhost", "universalistas", "u12345", "universalistas");
                $text = $_POST['text'];
                $option = $_POST['category'];
                $reg = mysqli_query($con, "INSERT INTO file (file, user_no_file, user_id_file, description_file, category_file) VALUES 
                    ('".$destination."', '".$user."', '".$user_id."', '".$text."', '".$option."')") or die(mysqli_error($con));
                if($reg) 
                {

ob_end_flush() ?>

<?php ob_start();

            header("Location: index.php?r=true");

ob_end_flush()?>

<?php ob_start();      

            }//End if($reg...
            else echo "Error.";
            }//end else
        }//end if(isset($_POST['guardar']))
    }//end if(isset(ses...
    else echo "No estas logueado";

ob_end_flush() ?>

introducir el código aquí
7
  • 1
    de casualidad usas wordpress o algun otro CMS? has configurado correctamente los settings de php.ini ?
    – fredyfx
    el 20 ene. 2017 a las 22:48
  • 1
    no, no uso wordpress. no he configurado php.ini(qué es?) el 20 ene. 2017 a las 22:51
  • 1
    aqui hermano, lectura recomendada: php.net/manual/es/ini.core.php
    – fredyfx
    el 20 ene. 2017 a las 22:54
  • 1
    Acabo de descubrir que tampoco sube archivos pequeños. el 21 ene. 2017 a las 0:35
  • 1
    y si colocas el código de tu proyecto?
    – fredyfx
    el 21 ene. 2017 a las 0:39

1 respuesta 1

1

Necesitas definir el valor de upload_max_filesize y post_max_size en tu php.ini :

; Maximum allowed size for uploaded files.
upload_max_filesize = 10M

; Must be greater than or equal to upload_max_filesize
post_max_size = 10M
1
  • 1
    ok ya lo modifiqué, sigue haciendo lo mismo. Resulta que godaddy tiene un panel que permite modificarlo. el 20 ene. 2017 a las 23:03

Tu Respuesta

Al pulsar en “Publica tu respuesta”, muestras tu consentimiento a nuestros términos de servicio, política de privacidad y política de cookies

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.