Robustupload use to upload images.
When loading the images above to approximately 2 mega bytes the system does not go forward continues to make attempts.
I wanted to know if there is a limit on the page and how I can disable the use of upload.php upload Verify integrity, because I think dipensa than the maximum weight of files to be uploaded.
thanks
This is my code:
<?php
//This variable specifies relative path to the folder, where the gallery with uploaded files is located.
//Do not forget about the slash in the end of the folder name.
$galleryPath = "../Gallery/";
$absGalleryPath = realpath($galleryPath) . "/";
function saveUploadedFiles()
{
global $absGalleryPath;
//Get the source file.
//NOTE: Since each file is uploaded in a separate request (because
//FilesPerOnePackageCount param equals to 1), you should work only
//with POST fields with index = 1 (such as SourceFile_1, FileName_1, etc).
if (!$_FILES["SourceFile_1"]['size'] || !is_uploaded_file($_FILES["SourceFile_1"]['tmp_name']))
{
header("HTTP/1.0 400 Bad Request");
return;
}
//Verify upload integrity. To do it, get the source file, compute hash value for it,
//and compare the result with the hash value calculated by Image Uploader.
//NOTE: In real-life application a single hash method is typically enough.
//Get SHA1 Hash.
//Check if this value is actually uploaded.
if (array_key_exists("HashCodeSHA_1", $_POST))
{
$postedSHA1Hash = $_POST ["HashCodeSHA_1"];
//Compute SHA1 hash. Since Image Uploader sends the hash value encoded with Base 64 algorithm
//the result should be also encoded with Base 64.
$actualSHA1Hash = base64_encode(pack("H*",sha1_file($_FILES["SourceFile_1"]['tmp_name'])));
//If the result differs from the uploaded one, the upload should be interpreted as corrupted.
if ($postedSHA1Hash != $actualSHA1Hash)
{
header("HTTP/1.0 400 Bad Request");
return;
}
}
//Get MD5 hash.
//Check if this value is actually uploaded.
if (array_key_exists("HashCodeMD5_1", $_POST))
{
$postedMD5Hash = $_POST ["HashCodeMD5_1"];
//Compute MD5 hash. Since Image Uploader sends the hash value encoded with Base 64 algorithm
//the result should be also encoded wi th Base 64.
$actualMD5Hash = base64_encode(pack("H*",md5_file($_FILES["SourceFile_1"]['tmp_name'])));
//If the result differs from the uploaded one, the upload should be interpreted as corrupted.
if ($postedMD5Hash != $actualMD5Hash)
{
header("HTTP/1.0 400 Bad Request");
return;
}
}
//If we reach this line, it means that file was not corrupted during upload.
//In this case we should save it to disk.
//Before saving uploaded files let's delete previously uploaded items.
//
//In this code sample each file is uploaded with a separate request. It means that this
//page will be called for each file individually (rather than once for all files). Therefore
//we need a way to determine whether this page is called for new upload session or not.
//
//To do it we check a PackageIndex POST field which returns a number of the request in the upload session.
//If it is the very first package we should delete all files we uploaded before.
//Otherwise, previously uploaded files belong to the same upload session and we should not delete them.
$packageIndex = $_POST ["PackageIndex"];
//If we receive the first file, we delete all files and thumbnails we uploaded before.
if ($packageIndex == 0)
{
//Delete source images
$handle = opendir($absGalleryPath . "/");
while (false !== ($file = readdir($handle)))
{
if (is_file($absGalleryPath . "/" .$file))
{
unlink($absGalleryPath . "/" . $file);
}
}
closedir($handle);
}
//NOTE: If you do not want to delete previously uploaded files, just
//remove or comment out the code above.
//Save the uploaded file to disk.
move_uploaded_file($_FILES["SourceFile_1"]['tmp_name'], $absGalleryPath . getSafeFileName($_FILES["SourceFile_1"]['name']));
}
//This method verifies whether file with such name already exists
//and if so, construct safe filename name (to avoid collision).
function getSafeFileName($fileName)
{
global $absGalleryPath;
$newFileName = $fileName;
$j = 1;
while (file_exists($absGalleryPath . "/" . $newFileName))
{
$newFileName = $j . "_" . $fileName;
$j = $j + 1;
}
return $newFileName;
}
saveUploadedFiles();
?>