1. Setting temporary file location
PHP File Uploader streams the data into a temporary file while the data is received. By default PHP File Uploader will use the system temporary directory (upload_tmp_dir), which can typically be accessed by all system users. If system temporary directory is not readable or writable by PHP user, you must specify a temporary file location. You should ensure that the PHP user has read/write permission to this specified folder.
You can easily specify the temporary file location using TempDirectory property:
- //Register Uploader component to your page
- <?php require_once "phpuploader/include_phpuploader.php" ?>
- <html>
- <body>
- <form id="form1" method="POST">
- <?php
- // Create Uploader object.
- $uploader=new PhpUploader();
- // Set a unique name to Uploader
- $uploader->Name="myuploader";
- // specify the temporary file location using TempDirectory property
- $uploader->TempDirectory="/mytempfolder";
- // Render Uploader
- $uploader->Render();
- ?>
- </form>
- </body>
- </html>
2. Setting MaxSizeKB
For security purpose, you should specify the limit for the size of uploaded file through MaxDataSize, in kilobytes. This limit can be used to prevent denial of service attacks that are caused, for example, by users uploading large files to the server. The default is no limit.
You can easily specify the maximum allowed size of the file using MaxSizeKB property:
- //Register Uploader component to your page
- <?php require_once "phpuploader/include_phpuploader.php" ?>
- <html>
- <body>
- <form id="form1" method="POST">
- <?php
- // Create Uploader object.
- $uploader=new PhpUploader();
- // Set a unique name to Uploader
- $uploader->Name="myuploader";
- // Specify the maximum allowed size of the file using MaxSizeKB property
- $uploader->MaxSizeKB=1024000;
- // Render Uploader
- $uploader->Render();
- ?>
- </form>
- </body>
- </html>