-
-
Save ElyDotDev/131c2c665ded9768cb71 to your computer and use it in GitHub Desktop.
SecureUPload – PHP secure file upload package Documentation: http://projects.allii.ir/project/secureupload/documentation/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$Config = new Alirdn\SecureUPload\Config\Config( | |
array( | |
'config_id' => 'config_value', | |
'config_another_id' => 0 | |
) | |
); | |
echo $Config->get('config_id'); // echo config_value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$Config = new Alirdn\SecureUPload\Config\Config(); | |
$Config->setArray( | |
array( | |
'config_id' => 'config_value', | |
'config_another_id' => 0 | |
) | |
); | |
echo $Config->get('config_id'); // echo config_value | |
echo $Config->get('config_another_id'); // echo 0 | |
echo $Config->get('config_non_exist_id'); // echo (empty string) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$Config = new Alirdn\SecureUPload\Config\Config(); | |
$Config->setArray( | |
array( | |
'config_id' => 'config_value', | |
'config_another_id' => 0 | |
) | |
); | |
$Config->printAll(); | |
/* | |
Output: | |
<pre> | |
Array | |
( | |
[config_id] => config_value | |
[config_another_id] => 0 | |
) | |
</pre> | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$Config = new Alirdn\SecureUPload\Config\Config; | |
$Config->set('config_id','config_value'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$Config = new Alirdn\SecureUPload\Config\Config(); | |
$Config->setArray( | |
array( | |
'config_id' => 'config_value', | |
'config_another_id' => 0 | |
) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$Config = new Alirdn\SecureUPload\Config\Config(); | |
$Config | |
->setArray( | |
Array | |
( | |
[config_id] => config_value | |
[config_another_id] => 0 | |
) | |
) | |
->set('final_config_id', 'final_value'); | |
echo $Config->get('config_id'); // echo config_value | |
echo $Config->get('config_another_id'); // echo 0 | |
echo $Config->get('config_non_exist_id'); // echo (empty string) | |
echo $Config->get('final_config_id'); // echo final_value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once "src/autoloader.php" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<form> | |
<!-- First !--> | |
<input type="file" name="images[]" /> | |
<input type="file" name="images[]" /> | |
<input type="file" name="images[]" /> | |
<!-- Second !--> | |
<input type="file" name="images[]" multiple/> | |
<!-- For each of above example you should call $SecureUPload->uploadFiles('images'); !--> | |
</form> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$SecureUPloadConfig = new Alirdn\SecureUPload\Config\Config; | |
$SecureUPloadConfig->set('upload_folder', 'uploads' . DIRECTORY_SEPARATOR); | |
// Initialize Upload folder | |
$SecureUPload = new Alirdn\SecureUPload\SecureUPload($SecureUPloadConfig); | |
// Bypass Upload folder initialization | |
$SecureUPload = new Alirdn\SecureUPload\SecureUPload($SecureUPloadConfig, false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$SecureUPloadConfig = new Alirdn\SecureUPload\Config\Config; | |
$SecureUPloadConfig->set('upload_folder', 'uploads' . DIRECTORY_SEPARATOR); | |
// Initialize Upload folder | |
$SecureUPload = new Alirdn\SecureUPload\SecureUPload($SecureUPloadConfig); | |
$Upload = $SecureUPload->getUpload('ca259cef4b42be49f7548e31aca10a29_png'); | |
if($Upload->status == 1) { | |
// Upload is is correct and file exist | |
echo 'Uploaded file id is correct and file exist. Id: ' . $Upload->id . ' Path:' . $Upload->path; | |
} else { | |
// Given id is incorrect or file doesn't exist. | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$SecureUPloadConfig = new Alirdn\SecureUPload\Config\Config; | |
$SecureUPloadConfig->set('upload_folder', 'uploads' . DIRECTORY_SEPARATOR); | |
// Initialize Upload folder | |
$SecureUPload = new Alirdn\SecureUPload\SecureUPload($SecureUPloadConfig); | |
$SecureUPload->getUploadAsFile('ca259cef4b42be49f7548e31aca10a29_png'); | |
exit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$SecureUPloadConfig = new Alirdn\SecureUPload\Config\Config; | |
$SecureUPloadConfig->set('upload_folder', 'uploads' . DIRECTORY_SEPARATOR); | |
// Initialize Upload folder | |
$SecureUPload = new Alirdn\SecureUPload\SecureUPload($SecureUPloadConfig); | |
$upload_removed = $SecureUPload->removeUpload('ca259cef4b42be49f7548e31aca10a29_png'); | |
if($upload_removed) { | |
// Uploaded and stored file removed successfully. | |
} else { | |
// Even id is not correct, file dosent exist or removing from file system failed. | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$SecureUPloadConfig = new Alirdn\SecureUPload\Config\Config; | |
$SecureUPloadConfig->set('upload_folder', 'uploads' . DIRECTORY_SEPARATOR); | |
// Initialize Upload folder | |
$SecureUPload = new Alirdn\SecureUPload\SecureUPload($SecureUPloadConfig); | |
$Upload = $SecureUPload->uploadFile('attachment'); | |
/* Check that file uploaded or not. Then do corresponding action. */ | |
if ( $Upload->status ) { | |
// File has been set in <input type="file" name="file"/> | |
if ( $Upload->status == 1 ) { | |
echo 'File uploaded successfully. Id: ' . $Upload->id; | |
} else { | |
echo 'File didn\'t uploaded. Error code: ' . $Upload->error; | |
} | |
} else { | |
// No file is selected in input field | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$SecureUPloadConfig = new Alirdn\SecureUPload\Config\Config; | |
$SecureUPloadConfig->set('upload_folder', 'uploads' . DIRECTORY_SEPARATOR); | |
// Initialize Upload folder | |
$SecureUPload = new Alirdn\SecureUPload\SecureUPload($SecureUPloadConfig); | |
$uploads = $SecureUPload->uploadFiles('images'); | |
/* Check that file uploaded or not. Then do corresponding action. */ | |
if(!empty($uploads)) { | |
// Files for uploading have been selected | |
foreach($uploads as $Upload) { | |
if ( $Upload->status == 1 ) { | |
echo 'File uploaded successfully. Id: ' . $Upload->id; | |
} else { | |
echo 'File didn\'t uploaded. Error code: ' . $Upload->error; | |
} | |
} | |
} else { | |
// No files is selected in input fields | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$SecureUPloadConfig = new Alirdn\SecureUPload\Config\Config; | |
$SecureUPloadConfig->set('upload_folder', 'uploads' . DIRECTORY_SEPARATOR); | |
// Initialize Upload folder | |
$SecureUPload = new Alirdn\SecureUPload\SecureUPload($SecureUPloadConfig); | |
$SecureUPload->getUploadAsFile('ca259cef4b42be49f7548e31aca10a29_png'); | |
exit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$SecureUPloadConfig = new Alirdn\SecureUPload\Config\Config; | |
$SecureUPloadConfig->set('upload_folder', 'uploads' . DIRECTORY_SEPARATOR); | |
// Initialize Upload folder | |
$SecureUPload = new Alirdn\SecureUPload\SecureUPload($SecureUPloadConfig); | |
$Upload = $SecureUPload->getUpload('ca259cef4b42be49f7548e31aca10a29_png'); | |
if($Upload->status == 1) { | |
// Upload is is correct and file exist | |
// Echo $Upload->relative_url in image src etc... | |
} else { | |
// Given id is incorrect or file doesn't exist. So show an error or 404 not found | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$SecureUPloadConfig = new Alirdn\SecureUPload\Config\Config; | |
$SecureUPloadConfig->set('upload_folder', 'uploads' . DIRECTORY_SEPARATOR); | |
// Initialize Upload folder | |
$SecureUPload = new Alirdn\SecureUPload\SecureUPload($SecureUPloadConfig); | |
$upload_removed = $SecureUPload->removeUpload('ca259cef4b42be49f7548e31aca10a29_png'); | |
if($upload_removed) { | |
// Uploaded and stored file removed successfully. | |
} else { | |
// Even id is not correct, file dosent exist or removing from file system failed. | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$SecureUPloadConfig = new Alirdn\SecureUPload\Config\Config; | |
$SecureUPloadConfig->set('upload_folder', 'uploads' . DIRECTORY_SEPARATOR); | |
// Initialize Upload folder | |
$SecureUPload = new Alirdn\SecureUPload\SecureUPload($SecureUPloadConfig); | |
$uploads = $SecureUPload->uploadFiles('images'); | |
/* Check that file uploaded or not. Then do corresponding action. */ | |
if(!empty($uploads)) { | |
// Files for uploading have been selected | |
foreach($uploads as $Upload) { | |
if ( $Upload->status == 1 ) { | |
// Save id to database | |
} else { | |
// Show corresponding error. | |
} | |
} | |
} else { | |
// If file is neccessary show error, if not, no action needed. | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$SecureUPloadConfig = new Alirdn\SecureUPload\Config\Config; | |
$SecureUPloadConfig->set('upload_folder', 'uploads' . DIRECTORY_SEPARATOR); | |
// Initialize Upload folder | |
$SecureUPload = new Alirdn\SecureUPload\SecureUPload($SecureUPloadConfig); | |
$Upload = $SecureUPload->uploadFile('attachment'); | |
/* Check that file uploaded or not. Then do corresponding action. */ | |
if ( $Upload->status ) { | |
// File has been set in <input type="file" name="file"/> | |
if ( $Upload->status == 1 ) { | |
// Save id to database | |
} else { | |
// Show corresponding error. | |
} | |
} else { | |
// If file is neccessary show error, if not, no action needed. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment