This documentation is for the old version. Go to the latest Upload Suite docs

PHP Samples

This topic discusses how to deploy PHP demo applications on your server.

Note

To find information about how a specific application works, see the Samples by Application topic.

Installation Steps

PHP demo applications are located at the following folders of the Image Uploader SDK:

  • Samples/PHP_Library contains demo applications based on Image Uploader PHP library usage. Read more about the PHP library in the Inserting Image Uploader PHP into Page topic.
  • Samples/PHP_IUEmbed contains demo applications which use Image Uploader embedding scripts library to insert Image Uploader into a page.

So, to install PHP demo applications just follow the steps below:

  1. Copy all the files from the PHP_Library or PHP_IUEmbed folder to some directory on your web server.
  2. Make sure that the Gallery folder has enough permissions:
    • On Windows NT/2000/XP you should grant the modify permission to the Internet guest user (IUSR_<machinename>).
    • On Windows 2003 you should grant the modify permission to the NETWORK SERVICE group.
    • For *NIX systems you should specify appropriate permissions.
  3. The GD2 extension should be enabled for the Server Imaging Sample.
  4. Run a browser and type the URL of the demo applications start page (index.php in the root of the PHP_Library or PHP_IUEmbed folder).

Troubleshooting

Cannot Upload More than N Megabytes

The most typical cause of this problem is a server-side limitation for the maximum POST request length. Usually, it is specified to reduce the risk of DoS attacks. If the request size exceeds some specific value, it is considered malicious, and the upload is broken. In this situation Image Uploader displays the following error message:

Upload failed (the connection was interrupted).

To increase the limit of the maximum upload size, you should edit your php.ini file and configure your server.

Modifying php.ini

  1. Open the php.ini file. You can find it:
    • On Linux: /etc/php.ini
    • On Windows: c:\windows\php.ini
  2. Set the required limits:
    post_max_size = 100MB
    upload_max_filesize = 100MB
    
  3. Optionally, set the following parameters:
    • memory_limit
    • upload_tmp_dir
    • max_execution_time

To make sure that new settings are applied, use the phpinfo() function which outputs information about the current state of PHP.

PHP
<?php 
	phpinfo();
?>

Configuring Apache Web Server

If you use the Apache web server, you should also edit the php.conf file.

  1. Open the php.conf file. You can find it:
    • On Linux: /etc/httpd/conf.d/php.conf
    • On Windows: <Apache installation folder>\conf\php.conf
  2. Change the LimitRequestBody parameter according to the post_max_size value, e.g.:

    LimitRequestBody 104857600

  3. Restart Apache.

Configuring IIS Web Server

For IIS 7:

  1. Go to C:\Windows\System32\inetsrv\config\applicationHost.config and change

    XML
    <section name="requestFiltering" overrideModeDefault="Deny" />

    to:

    XML
    <section name="requestFiltering" overrideModeDefault="Allow" />
  2. Add to your application's web.config the following sections:

    XML
    <system.webServer>
        <security>
            <requestFiltering>
                <requestLimits maxAllowedContentLength ="2147482624" /> <!-- in bytes -->
            </requestFiltering>
        </security>
    </system.webServer>
    XML
    <system.web>
         <httpRuntime maxRequestLength="2097151"/> <!-- in kilobytes -->
    </system.web>

For IIS 6:

XML
<system.web>
    <httpRuntime maxRequestLength="2097151"/> <!-- in kilobytes -->
</system.web>

If you have URLScan installed and still experience this problem, go through the following steps:

  1. Open the UrlScan.ini file which is typically located at C:\Windows\system32\inetsrv\urlscan folder.
  2. Set the MaxAllowedContentLength key to the desired value.
  3. Save changes and restart IIS.

Additionally, to reduce the length of the POST request sent by Image Uploader use the FilesPerOnePackageCount which specifies a number of files to send in a single request.

See Also

Manual