Uploader Script - Max File Size
Posted: Wed Nov 22, 2006 8:53 am
feyd | Please use
and this is the php file i use:[/syntax]
Please can someone point me in the right direction as to how i can specify the file size and or type of files being uploaded.
cheers
NoobieOobie
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi Guys,
I have managed to create a php file uploader and yes it works pretty sweet but thats about as far as my newly found php skills go.
I have been trying for ages to add some code to it so that i can either limit the file size a user uploads or just allow them to upload what ever size they want.
This is my form on my html page:
[syntax="html"]<form enctype="multipart/form-data" action="uploader.php" method="POST">
<table border="0" cellspacing="10" cellpadding="0">
<tr>
<td><input type="hidden" name="MAX_FILE_SIZE" value="100000000" />
Choose a file to upload: <span class="style12">(Max file size 100Mb)</span> </td>
<td><input name="uploadedfile" type="file" /></td>
<td><input name="submit" type="submit" value="Upload File" /></td>
</tr>
</table>
</form>Code: Select all
<?php
// Where the file is going to be placed
$target_path = "uploads/";
/* Add the original filename to our target path.
Result is "uploads/filename.extension" */
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
$_FILES['uploadedfile']['tmp_name'];
$target_path = "uploads/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
/*echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";*/
$URL="submit/submitsent.htm";
header ("Location: $URL");
} else{
/* echo "There was an error uploading the file, please try again!";*/
$URLWRONG="submit/submitfail.htm";
header ("Location: $URLWRONG");
}
?>cheers
NoobieOobie
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]