Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- subir.php
- ===============
- <form enctype="multipart/form-data" action="upload.php" method="POST">
- Seleccione un archivo: <input name="uploaded" type="file" /><br />
- <input type="submit" value="Upload" />
- </form>
- upload.php
- ==============
- <?php
- $target = "AQUÍ_VA_TU_RUTA_DE_SUBIDA";
- $target = $target . basename( $_FILES['uploaded']['name']) ;
- $ok=1;
- //This is our size condition
- if ($uploaded_size > 20000000)
- {
- echo "El archivo es demasiado grande. El límite es 20Mb.<br>";
- $ok=0;
- }
- //This is our limit file type condition
- if ($uploaded_type =="text/php")
- {
- echo "No se pueden subir archivos PHP<br>";
- $ok=0;
- }
- //Here we check that $ok was not set to 0 by an error
- if ($ok==0)
- {
- Echo "Lo sentimos, su archivo no se ha subido.";
- }
- //If everything is ok we try to upload it
- else
- {
- if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
- {
- echo "El archivo ". basename( $_FILES['uploadedfile']['name']). " se ha subido.";
- }
- else
- {
- echo "Lo sentimos, ha habido un problema subiendo su archivo.";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement