file uploading question
Posted: Wed May 11, 2005 11:20 am
Ok... I have a file upload script that works just fine and uploads files no problem. The only thing is that it seems to have a file size limit or something. I want to be able to set the limit and upload files up to or over a gig in size. Is this possible with what I have below? Do I need to do it different maybe?
This is what i have for the form:
This is what i have for the upload:
d11wtq | Please read the sticky about posting code in the forums
- USE
This is what i have for the form:
Code: Select all
print "<table width='$titlewide' $border>";
print "<form enctype='multipart/form-data' action='upload.php' method='post'>"; //upload_send
print "<input type='hidden' name='MAX_FILE_SIZE' value='943718400'>";
print "<tr height='20px' bgcolor='$bgcolour10'>";
IF ($rights_level == 9)
{ print "<td align='center' width='40px'><font size='2' color='white'><b>Del</b></font></td>"; }
print "<td width='10px'></td>";
print "<td><a href='upload.php?sort=fn'><font size='2' color='white'><b>File Name</b></font></a></td>";
print "<td><font size='2' color='white'><b>Ext.</b></font></td>";
print "<td width='20px'></td>";
print "<td><font size='2' color='white'><b>Type</b></font></td>";
print "<td width='20px'></td>";
print "<td align='right'><font size='2' color='white'><b>Size</b></font></td>";
print "<td width='170px' align='right'><a href='upload.php?sort=ud'><font size='2' color='white'><b>Upload Date</b></font></a></td>";
print "<td width='10px'></td>";
print "</tr>";This is what i have for the upload:
Code: Select all
///////////// Get File Info. \\\\\\\\\\\\\\
$file_name = $_FILES['userfile']['name'];
$file_type = $_FILES['userfile']['type'];
$file_size = $_FILES['userfile']['size'];
///////////// Upload File Script \\\\\\\\\\\\\\
$set_time_limit = set_time_limit(90); // Change FTP time-out limit from 'default' 30 seconds to different time (in seconds)
print "<table width='$titlewide'>";
$uploaddir = '/directory/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
IF ( $uploadfile != "" )
{
IF ( $file_size == 0 )
{
print "<table width='$titlewide' $border>";
print "<tr height='160px'>";
print "<td align='center'>";
print "<b>Uploaded file has no file size</b>";
print "<p>Want to go back to the <a href='upload.php'>upload/Download</a> page?";
print "</td>";
print "</tr>";
print "</table>";
}
// 1 KB = 1,024 Bytes
// 1 MB = 1,048,576 Bytes
// 1 GB = 1,073,741,824 Bytes
ELSEIF ( $file_size >= 3145728 ) // Current upload limit \\
{
print "<table width='$titlewide' $border>";
print "<tr height='160px'>";
print "<td align='center'>";
print "<b>File size too large must be under 3mb</b>";
print "<p>Want to go back to the <a href='upload.php'>upload/Download</a> page?";
print "</td>";
print "</tr>";
print "</table>";
}
ELSEIF (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) // Upload File Here
{
///////////// Insert File Info. into DB \\\\\\\\\\\\\\
$result = mysql_query("INSERT INTO files (file_name, file_type, file_size, upload_date) VALUES('$file_name', '$file_type', '$file_size', now())")
or die(mysql_error());
///////////// Print File Info. \\\\\\\\\\\\\\
print "<table width='$titlewide' $border>";
print "<tr height='40px'>";
print "<td width='60px'></td>";
print "<td width='100px'></td>";
print "<td></td>";
print "<td></td>";
print "</tr>";
print "<tr>";
print "<td></td>";
print "<td>File Name:</td>";
print "<td>$file_name</td>";
print "<td></td>";
print "</tr>";
print "<tr>";
print "<td></td>";
print "<td>File Type:</td>";
print "<td>$file_type</td>";
print "<td></td>";
print "</tr>";
print "<tr>";
print "<td></td>";
print "<td>File Size:</td>";
print "<td>$file_size"." kb</td>";
print "<td></td>";
print "</tr>";
print "</table>";
print "<table width='$titlewide' $border>";
print "<tr height='160px'>";
print "<td align='center'>";
print "<b>File Uploaded Successfully</b>";
print "<p>Want to go back to the <a href='upload.php'>upload/Download</a> page?";
print "</td>";
print "</tr>";
print "</table>";
}
ELSE
{
echo "Sorry, could not copy file into system.";
}
}
ELSE
{
print "<tr><td>There is no file to upload</td></tr>";
}
print "</table>";Code: Select all
tags!