user1714133
user1714133

Reputation: 79

Uploading file not working, to large

I am having trouble reading a file of large size roughly 25mb in PHP. I have tried altering the max input file size to 50mb and it still is not working. This is the code for the form.

<html>
<body>

<form action="parsed_xml.php" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value="Submit">
</form>

</body>
</html>

And this is the code for the PHP file:

<?php
if ($_FILES["file"]["error"] > 0)
  {
  echo "Error: " . $_FILES["file"]["error"] . "<br>";
  }
else
  {
  print_r ($_FILES["file"]);
  echo "Upload: " . $_FILES["file"]["name"] . "<br>";
  echo "Type: " . $_FILES["file"]["type"] . "<br>";
  echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
  echo "Stored in: " . $_FILES["file"]["tmp_name"];
  }
?>

I am not getting any errors, nothing is being stored in the $_FILES array.

Thanks

James

Upvotes: 1

Views: 1058

Answers (5)

user1735111
user1735111

Reputation:

If you have not an access to the php.ini file use the function "ini_set".

Upvotes: 0

c4pone
c4pone

Reputation: 797

Just increase the max file size in your "php.ini" or if you don't have access to the php.ini create a ".htaccess " in your web root.

Example 10MB:

 upload_max_filesize = 10M 
 post_max_size = 10M

Upvotes: 0

TheJSB
TheJSB

Reputation: 151

Check server's upload limit. You'll need to increase it in order to upload large files.

And just a check: have you restarted PHP process after changing the configuration?

Upvotes: 0

Prasanth Bendra
Prasanth Bendra

Reputation: 32730

Two PHP configuration options control the maximum upload size: upload_max_filesize and post_max_size. Both can be set to, say, “10M” for 10 megabyte file sizes.

However, you also need to consider the time it takes to complete an upload. PHP scripts normally time-out after 30 seconds, but a 10MB file would take at least 3 minutes to upload on a healthy broadband connection (remember that upload speeds are typically five times slower than download speeds). In addition, manipulating or saving an uploaded image may also cause script time-outs. We therefore need to set PHP’s max_input_time and max_execution_time to something like 300 (5 minutes specified in seconds).

You can set then using :

  1. in php.ini - set these values and restart server
  2. set it in htaccess
  3. Set in your php code using ini_set

Ref: http://www.sitepoint.com/upload-large-files-in-php/

Upvotes: 2

Karl
Karl

Reputation: 5463

Sounds to me that you need to increase the limits set by Apache, in your php.ini file:

post_max_size=50M
upload_max_filesize=50M

If you don't have access to the ini file, ask your host to increase the limits.

Upvotes: 4

Related Questions