I'm trying to create a page where users can upload files to my server space. Since some of the files will be high-res images, the size of the uploaded files may go up to 50 megs. The code works perfectly when uploading files smaller than 1 meg. But if the file is any bigger than 1 meg, I get "The page cannot be displayed" error. I don't think it's a timeout related problem, since the error page opens immediately after I click the upload button (and the file is bigger than 1 meg, of course).
I figured the problem would be the upload_max_filesize in my ISP's php.ini file. But they are using the default limit of 2 megs. They suggested I should use a .htaccess file to raise the limit myself, which I then did. I set up the .htaccess file as described below, but the problem remains.
Now I've started to wonder, could the problem be in my php code? I've searched all the forums, but haven't had any luck. Any help what so ever would be highly appreciated...
Here's my .htaccess:
php_flag file_uploads "On"
php_value max_execution_time "600"
php_value upload_max_filesize "10M"
php_value post_max_size "10M"
php_value memory_limit "10M"
And here's the php file (I found the code from one of the forums and then modified it a bit):
<?php
if ($submit)
{
$ftp_server = "xxx.xxx.xx.xx";
$ftp_user_name = "username";
$ftp_user_pass = "password";
// set up basic connection
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// check connection
if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has failed!";
echo "Attempted to connect to $ftp_server for user $ftp_user_name";
die;
} else {
echo "Connected to $ftp_server, for user $ftp_user_name";
}
$newdir = "/material";
ftp_chdir($conn_id, $newdir);
$tmp = $HTTP_POST_FILES["filename"]['name'];
$source_file = $filename;
$destination_file = $tmp;
// upload the file
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
// check upload status
if (!$upload) {
echo "FTP upload has failed!";
} else {
echo "Uploaded $source_file to $ftp_server as $destination_file";
}
// close the FTP stream
ftp_close($conn_id);
}
else
{
?>
<form method="post" action="<?php echo $PHP_SELF; ?>" enctype="multipart/form-data">
<br>File to upload in to our server:<br>
<inpyt type="hidden" name="MAX_FILE_SIZE" value="20000000">
<input type="file" name="filename" size="40">
<p><input type="submit" name="submit" value="submit">
</form>
<?
}
?>