Oct
22
2007

Upload file (cargar archivo) PHP

Validaciones en upload.php

< ?php
//Limita el tamaño máximo del archivo que se sube a 10M, en código upload.php
 
//to lowerCase
//Para dejar todo en minúsculas
$tipo_archivo= strtolower($tipo_archivo);
 
  //Valida para saber si el archivo esta en el directorio temporal (directorio temporal revisa php.ini)
   if (!($HTTP_POST_FILES['doc_file']['tmp_name']!='')){
 
   echo 'without file'; //cuando se carga mal un archivo
   exit();
}
 
 //validación para verificar la extensión del archivo
 //TODO
 //validación para limitar el tamaño del archivo
 if (($tamano_archivo > $filesize_limit_upload)) {
  echo "The file size is upper the limit, the max size allowed is $filesize_limit_upload bytes";
  exit();
 }
 
 if (move_uploaded_file($HTTP_POST_FILES['doc_file']['tmp_name'], $dir_base_uploadDoc.$doc_filename)){
 
 }else{
  print("Some error can´t complete your requirement");
  exit();
 }
 
?>

Problems while uploading the document (problemas al tratar de cargar el archivo):

Warning: fread(): supplied argument is not a valid stream resource in

Warning: fclose(): supplied argument is not a valid stream resource in

Chech (Revisar) php.ini

upload_max_filesize = 2M;
post_max_size = 8M;

También revisar las siguientes variables (Also check if):

(post_max_size > upload_max_filesize).

Written by doutdex in: PHP | Tags: , ,

2 Comments »

  • GA says:

    Hola es un muy beun aporte a la comunidad

  • Geniux says:

    otra forma de poder hacer esto es la siguiete, es mas sencilla, pero igual funciona; claro que tenemos q tener dos archivos, uno en donde tendremos los frames y nada de PHP y otro en donde tendremos PHP. ejemplo:

    html>

    conframe

    Seleccione el archivo:

    soloPHP

    <?php
    copy($_FILES['foto']['tmp_name'],$_FILES['foto']['

    name']);
    echo “La foto se registro en el servidor.”;
    $nom=$_FILES['foto']['name'];
    echo “”;
    ?>

RSS feed for comments on this post. TrackBack URL


Leave a Reply

TheBuckmaker.com Wordpress Themes | Geld von Privat, Streaming Audio
футбол онлайн, live football, canlı izle, football streaming, football forum, football forums, canlı maç, football highlights, maç özeti, live football streaming, stream live football, free football streaming,