Jump to content

Uploading files


CanMan2004

Recommended Posts

The size of the file allowable for upload can be set in the php.ini

If you have a script and it works on small files, then it is not the script that is the problem, often it is a result of default settings in php.ini. The ini file often needs to be configured for large files sizes, long execution times, and post size. All of these need to be tweaked so your large files can be processed.

Also ensure that you have set  MAX_FILE_SIZE in a hidden input preceding your file field(s).
   
    <input type="hidden" name="MAX_FILE_SIZE" value="4000000" ><!--max_file_size value in bytes. -->

If you are experiencing ANY error messages when attempting to upload files it could be because:


The webserver (as in the webserver process - not you as a user of the web application) does not have permission to write to the files directory(ies). The files directory under dotProject AND its associated subdirectories must have write permissions for the webserver process.


You need to ensure that PHP has the following STANDARD PHP SETTINGS sorted out:
file_uploads must be set to on
post_max_size and upload_max_filesize must BOTH be set to the maximum file size you expect

Change the above ini settings. Read: http://www.radinks.com/upload/config.php for more info on ini configurations. Test using http://ca.php.net/features.file-upload script example.

Tomasz


Link to comment
Share on other sites

Hi all

I've used the easiest of uploads scripts to try and get this working, the code I have used is;

[code]<?php
if ($_POST['action'] = 'upload')
{
      $tmp_name = $_FILES["pictures"]["tmp_name"];
      $name = $_FILES["pictures"]["name"];
      move_uploaded_file($tmp_name, "data/$name");
}
?>

<form action="" method="post" enctype="multipart/form-data">
<p>Pictures:
<input type="file" name="pictures" />
<input type="hidden" name="action" value="upload" />
<input type="submit" value="Send" />
</p>
</form>[/code]

When I load the page and try to upload a large file, after about 30 seconds, the browser seems to time out and reload the page again without uploading the file I selected, it seems to be okay for files under 600KB, but nothing larger, although, firefix seems to have more luck than Internet Explorer.

To try and fix this, I took the last suggestion which was to add

[code]php_value upload_max_filesize "20M"[/code]

to a blank text file and saved it as

[code].htaccess[/code]

I then uploaded the file and ran the page again, this time, after around 30 seconds, it seems to display

The page cannot be displayed

If I then refresh the page, I get the message

Internal Server Error

and cannot even upload small files.

Previous to this, I tried adding

[code]post_max_size=400000
upload_max_filesize=400000
max_execution_time=400000
max_input_time=400000[/code]

to a

[code]php.ini[/code]

file, but it didnt seem to effect anything.

Can anyone give me any help or guidence?

Thanks in advance for any help

Ed
Link to comment
Share on other sites

If I check the error log, I get the following message

[code][Mon Oct  2 13:05:29 2006] [alert] [client **.***.**.***] /home/theworks/public_html/cp/.htaccess: Invalid command 'php_value', perhaps mis-spelled or defined by a module not included in the server configuration[/code]

Any ideas? I'm on a shared hosting account
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.