After an exhausting search for more than 5 hours and reading almost every php forum on internet; I finally decided to post here to see if I can get some help. I have a php script which is basically a form to upload a single file. But unfortunatelly I can't get it to work for large files. The purpose of this is because some friends want to share files with me sometimes and I want to use this form since emails don't allow to send files of about 2GB or 4GB size. the script uses ftp connections since http does not support such a files sizes. I've changed some things in my php.ini but with no success. It does work with small files. At this point I don't know what to do.
Here is my actual php config(only changed memory limit and post max size):
Code: Select all
max_execution_time = 30
max_input_time = 60
memory_limit = 3072M
post_max_size = 5120M
default_socket_timeout = 60
INDEX.PHP
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>some title here</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
.center{
margin-left:30%;
margin-right:30%;
width:40%;
padding:0 0 23px 25px;
background-color:#b0e0e6;
}
</style>
</head>
<body>
<div class="center" ><form enctype="multipart/form-data" action="upload.php" method="post">
<p><br>
<br>
<h1>Upload File</h1></p>
<br />
<label>Select User:</label>
<select name="usr">
<option value="<?php echo 'user1'?>">user1</option>
<option value="<?php echo 'user2'?>">user2</option>
<option value="<?php echo 'user3'?>">user3</option>
</select>
<br />
<br />
<label>Password:</label>
<input type="password" name="pwd">
<p>
<input name="userfile" type="file" />
</p>
<p><br>
<input type="submit" value="Submit" />
<br>
</p>
</form></div>
</body>
</html>
Code: Select all
<?php
set_time_limit(9000000);
$ftp_server = "ftp.myserver.com";
// set up a connection or die
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");
// try to login
//if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
if (@ftp_login($conn_id, $_POST['usr'], $_POST['pwd'])) {
echo '<div style="margin-left:30%;margin-right:30%;width:40%;padding:0 0 23px 25px;background-color:#b0e0e6;" ><h3>Connected to server. Please wait...</h3></div>';
} else {
echo "Connection was unsuccessful";
}
$remote_file = $_FILES['userfile']['name'];;
//v important this one as you have to use the tmp_file created for the actual upload
$file = $_FILES['userfile']['tmp_name'];
if (ftp_put($conn_id, $remote_file, $file, FTP_BINARY)) {
echo '<h1 style="text-align:center;">Successfully Uploaded File</h1>';
} else {
echo "Error uploading the file";
}
// close the connection
ftp_close($conn_id);
?>