Jump to content

[SOLVED] Uploading files from multipart forms problem


flaab

Recommended Posts

Hi all =)

 

I'm programming a simple upload file php script.

 

The thing is...it works. But only with small files =S and I need it to be able to receive large files (up to 100 mb if neccesary).

 

Here's the code, pretty simple yet. It just receives a file, checks extension and if correct, updloads it.

 

Uploading a small file works, but if is a large file it fails.

 

Where can i change the max file size allowed to upload to my server? Thanks.

 

<?php

/*******************************************************
*
* DP UPLOADER
* Version 0.1
*
* Recibe fichero a subir
*
* Comprueba tamaño y extension
* Lo sube a un directorio con el nombre adecuado.
*
********************************************************/

/*************************
* PROCESO
**************************/

if(isset($_POST['submit'])) {

/*
* CONFIGURACION
*/

$target_path = "files/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 
$ALLOWED_EXT = array("mpg","mpeg","avi","qt","mov","txt");

/*****************************************
* COMPROBACIONES:
* a) De formatos
* b) De tamaño
*****************************************/

// Capturamos extensión
$ext = explode(".", $_FILES['uploadedfile']['name']);
$ext = $ext[count($ext) - 1];

if(!in_array($ext, $ALLOWED_EXT)) {

	$error = "Extension no permitida";	

}

if(!$error) {

	if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {

 		   echo "The file ".  basename( $_FILES['uploadedfile']['name']). " has been uploaded";
 		   
	} else{

   		 echo "There was an error uploading the file, please try again!";
   		 
	}

} else {

	echo $error;

}



} else {

/*********************
* FORMULARIO
*********************/

?>

<form enctype="multipart/form-data" action="dp_uploader.php" method="POST">
Elige archivo a enviar: <input name="uploadedfile" type="file" /><br />
<input type="submit" name="submit" value="Upload">
</form>

<?php 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.