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 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.