Set file upload limit size
Set file upload limit size
############### Code
<table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form action="limit_upload_ac.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td><strong>File Upload (Limit file size 50 K)</strong></td>
</tr>
<tr>
<td align="center">Select file
<input name="ufile" type="file" id="ufile" size="35" /></td>
</tr>
<tr>
<td align="center"><input type="submit" name="Submit" value="Upload" /></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
Create file limit_upload_ac.php
############### Code
<?php
// Define file size limit
$limit_size=50000;
//set where you want to store files
//in this example we keep file in folder upload
//$HTTP_POST_FILES['ufile']['name']; = upload file name
//for example upload file name cartoon.gif . $path will be upload/cartoon.gif
$path= "upload/".$HTTP_POST_FILES['ufile']['name'];
if($ufile !=none)
{
// Store upload file size in $file_size
$file_size=$HTTP_POST_FILES['ufile']['size'];
if($file_size >= $limit_size){
echo "Your file size is over limit<BR>";
echo "Your file size = ".$file_size;
echo " K";
echo "<BR>File size limit = 50000 k";
}
else {
//copy file to where you want to store file
if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path))
{
echo "Successful<BR/>";
echo "<img src=\"$path\" width=\"150\" height=\"150\">";
}
else
{
echo "Copy Error";
}
}
}
?>
<table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form action="limit_upload_ac.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td><strong>File Upload (Limit file size 50 K)</strong></td>
</tr>
<tr>
<td align="center">Select file
<input name="ufile" type="file" id="ufile" size="35" /></td>
</tr>
<tr>
<td align="center"><input type="submit" name="Submit" value="Upload" /></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
Create file limit_upload_ac.php
############### Code
<?php
// Define file size limit
$limit_size=50000;
//set where you want to store files
//in this example we keep file in folder upload
//$HTTP_POST_FILES['ufile']['name']; = upload file name
//for example upload file name cartoon.gif . $path will be upload/cartoon.gif
$path= "upload/".$HTTP_POST_FILES['ufile']['name'];
if($ufile !=none)
{
// Store upload file size in $file_size
$file_size=$HTTP_POST_FILES['ufile']['size'];
if($file_size >= $limit_size){
echo "Your file size is over limit<BR>";
echo "Your file size = ".$file_size;
echo " K";
echo "<BR>File size limit = 50000 k";
}
else {
//copy file to where you want to store file
if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path))
{
echo "Successful<BR/>";
echo "<img src=\"$path\" width=\"150\" height=\"150\">";
}
else
{
echo "Copy Error";
}
}
}
?>
Similar topics
» Php file upload
» updating configuration file in browser
» Function to validate file extension ( PHP )
» Check if a file exists on a remote FTP server with PHP
» updating configuration file in browser
» Function to validate file extension ( PHP )
» Check if a file exists on a remote FTP server with PHP
Permissions in this forum:
You cannot reply to topics in this forum
Fri Jul 22, 2011 1:37 pm by shyamsunder
» Thousands of Free PHP Scripts Recommended
Wed May 18, 2011 10:33 am by bizboy12
» PHP form validation problem?
Wed Jan 12, 2011 1:25 pm by simy202
» string wrap
Sat Aug 02, 2008 2:06 pm by scvinodkumar
» retrieving current date rows
Tue Jul 15, 2008 3:25 am by scvinodkumar
» number in words
Tue Apr 29, 2008 3:10 pm by scvinodkumar
» Simple PHP Form Field Generator
Fri Apr 25, 2008 12:28 pm by scvinodkumar
» PHP password generator
Fri Apr 18, 2008 7:24 pm by scvinodkumar
» PHP Script to Extract Email Address from any text
Fri Apr 18, 2008 7:18 pm by scvinodkumar