Ini_set() Function Seemingly Not Working

Causing Upload Script to Disallow Large Files

Page 1 of 1

3 Replies - 5177 Views - Last Post: 13 September 2010 - 12:56 AM Rate Topic: -----

#1 Cbeppe  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 31
  • View blog
  • Posts: 216
  • Joined: 16-September 09

Ini_set() Function Seemingly Not Working

Posted 12 September 2010 - 12:51 PM

Hello DIC,

I recently coded a quick script to work as a file sharing site that I use to transfer files from my school laptop to my home computer. It works perfectly with small files, but when I try to upload a 4MB audio file, I get the "UPLOAD_ERR_INI_SIZE" (1) from the "$_FILES['file']['error']" variable despite setting ini_set("upload_max_filesize","2000M").

I'm unsure why the ini_set function is not working, but I'm hoping you know something I don't :)

Here are the two files I'm working with:

index.php: (Only form part)
<form enctype="multipart/form-data" action="upload.php" method="post"/>
<input type="file" name="file" size="50"/><br />
<input type="submit" value="Upload">
</form>



upload.php: (Entire File)
<?php
error_reporting(E_ALL);
ini_set('max_execution_time', 18000);
ini_set("memory_limit","202M");
ini_set("time_limit","5555");
ini_set("post_max_size","2001M");
ini_set("upload_max_filesize","2000M");

$filename = $_FILES["file"]["name"];
$filename = str_replace(' ', '_', $filename);
$uploaddir = 'files/';
$uploadfile = $uploaddir . basename($filename);
echo $_FILES['file']['error'];
if (file_exists($uploadfile)){
	die('This Filename Exists! Please rename your file and check if it has been uploaded before.<br /><br /><a href="http://example.com">Back</a>');
}
move_uploaded_file($_FILES["file"]["tmp_name"],$uploadfile);
header('location:index.php');
?>


Thanks in advance.
Cbeppe

Is This A Good Question/Topic? 0
  • +

Replies To: Ini_set() Function Seemingly Not Working

#2 mahcuz  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 143
  • View blog
  • Posts: 213
  • Joined: 03-June 10

Re: Ini_set() Function Seemingly Not Working

Posted 12 September 2010 - 01:11 PM

upload_max_filesize cannot be set via ini_set - it's a PHP_INI_PERDIR item, and can be set in the php.ini config file, .htaccess or httpd.conf files.

BTW, you could just use something like SCP to transfer the files, but, hey, there's no harm in using your skills for little scripts.

This post has been edited by mahcuz: 12 September 2010 - 01:13 PM

Was This Post Helpful? 2
  • +
  • -

#3 Cbeppe  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 31
  • View blog
  • Posts: 216
  • Joined: 16-September 09

Re: Ini_set() Function Seemingly Not Working

Posted 12 September 2010 - 01:36 PM

Thanks for clearing that up. I'll see if I can access the php.ini file. You never know with free hosts...

I looked up SCP (yeah, I never heard of it...) and it seemed like a good solution for transfering, but part of the idea behind using a website is that there's always an extra backup, and there's no need for both computers to be on and connected at the same time.

Also, skills need to be practiced every now and then. Especially when I haven't had a project for a while.

Again, thanks for the clarification. I really appreciate the quick answer :)
Was This Post Helpful? 0
  • +
  • -

#4 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 4154
  • View blog
  • Posts: 13,146
  • Joined: 08-June 10

Re: Ini_set() Function Seemingly Not Working

Posted 13 September 2010 - 12:56 AM

View PostCbeppe, on 12 September 2010 - 08:36 PM, said:

I'll see if I can access the php.ini file. You never know with free hosts...

unlikely you get access (on a shared server, this could break PHP if you screw up). probably your best bet is .htaccess.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1