SHARE
TWEET

Uploader

bi0xid May 15th, 2012 231 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. subir.php
  2. ===============
  3.  
  4.  <form enctype="multipart/form-data" action="upload.php" method="POST">
  5.  Seleccione un archivo: <input name="uploaded" type="file" /><br />
  6.  <input type="submit" value="Upload" />
  7.  </form>
  8.  
  9.  
  10. upload.php
  11. ==============
  12.  
  13. <?php
  14.  $target = "AQUÍ_VA_TU_RUTA_DE_SUBIDA";
  15.  $target = $target . basename( $_FILES['uploaded']['name']) ;
  16.  $ok=1;
  17.  
  18.  //This is our size condition
  19.  if ($uploaded_size > 20000000)
  20.  {
  21.  echo "El archivo es demasiado grande. El límite es 20Mb.<br>";
  22.  $ok=0;
  23.  }
  24.  
  25.  //This is our limit file type condition
  26.  if ($uploaded_type =="text/php")
  27.  {
  28.  echo "No se pueden subir archivos PHP<br>";
  29.  $ok=0;
  30.  }
  31.  
  32.  //Here we check that $ok was not set to 0 by an error
  33.  if ($ok==0)
  34.  {
  35.  Echo "Lo sentimos, su archivo no se ha subido.";
  36.  }
  37.  
  38.  //If everything is ok we try to upload it
  39.  else
  40.  {
  41.  if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
  42.  {
  43.  echo "El archivo ". basename( $_FILES['uploadedfile']['name']). " se ha subido.";
  44.  }
  45.  else
  46.  {
  47.  echo "Lo sentimos, ha habido un problema subiendo su archivo.";
  48.  }
  49.  }
  50.  ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top