Bonjour,
J'ai un pb avec is_uploaded_file qui me génère une erreur. Si je l'enlève est ce que cela peut poser un pb au niveau de sécurité ?
1 2
| // if ( isset($_FILES[$this->_file]['tmp_name']) && !empty($_FILES[$this->_file]['tmp_name']) && is_uploaded_file($_FILES[$this->_file]['tmp_name']) && ($_FILES[$this->_file]['size'] > 0) ) {
if ( isset($_FILES[$this->_file]['tmp_name']) && !empty($_FILES[$this->_file]['tmp_name']) && ($_FILES[$this->_file]['size'] > 0) ) { |
Explication
J'ai une erreur quen j'essaye de télécharger une image / fichier.
L'image est téléchargée mais l'erreur aparait tout le temps.
[08-Sep-2016 09:45:29 America/New_York] PHP Notice: File Upload [POST]: Cannot process $_FILES[products_image_resize]['tmp_name'] in /home/www/boutique/includes/OM/Upload.php on line 73
Line 73 o Upload class
1 2 3 4 5 6 7 8 9 10
| if ( isset($_FILES[$this->_file]) ) {
if ( isset($_FILES[$this->_file]['tmp_name']) && !empty($_FILES[$this->_file]['tmp_name']) && is_uploaded_file($_FILES[$this->_file]['tmp_name']) && ($_FILES[$this->_file]['size'] > 0) ) {
$this->_upload = array('type' => 'POST',
'name' => $_FILES[$this->_file]['name'],
'size' => $_FILES[$this->_file]['size'],
'tmp_name' => $_FILES[$this->_file]['tmp_name']);
} else {
trigger_error('File Upload [POST]: Cannot process $_FILES[' . $this->_file . '][\'tmp_name\']');
}
} |
Ma classe class products : function getImage()
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
// load originale image
$image = new Upload('products_image_resize', DIR_FS_CATALOG_IMAGES . $dir_products_image, null, array('gif', 'jpg', 'png'));
if ( $image->check() && $image->save() ) {
$error = false;
}
if ( $error === false ) {
$sql_data_array['image'] = $dir_products_image . $separator . $image->getFilename();
} else {
$sql_data_array['image'] = '';
$OSCOM_MessageStack->add(ERROR_CATALOG_IMAGE_DIRECTORY_NOT_WRITEABLE, 'warning');
} |
appellé par
1 2
| // image
$this->getImage(); |
Mon fichier HTML
<form name="new_product" action="http://boutique/admin/index.php?Products&cPath=&pID=3&action=update_product" method="post" enctype="multipart/form-data">
test
1 2 3 4 5 6 7 8 9 10 11 12
|
//print_r($_FILES[$this->_file]);
// Array ( [name] => [type] => [tmp_name] => [error] => 4 [size] => 0 ) - no files
//Array ( [name] => shopping-bag.png [type] => image/png [tmp_name] => /tmp/phpOg7mnD933577 [error] => 0 [size] => 933577 ) - files
print_r($_FILES[$this->_file]['tmp_name']); // 0 - no files
print_r($_FILES[$this->_file]['size']); // 0 - no file;
print_r($_FILES[$this->_file]['tmp_name']); // //tmp/phpOg7mnD933577 - files
print_r($_FILES[$this->_file]['size']); // /tmp/phpOg7mnD933577g - file; |
line to test
if ( isset($_FILES[$this->_file]['tmp_name']) && !empty($_FILES[$this->_file]['tmp_name']) && is_uploaded_file($_FILES[$this->_file]['tmp_name']) && ($_FILES[$this->_file]['size'] > 0) ) {
remplacé par
1 2 3 4
|
if (!empty($_FILES[$this->_file]['tmp_name'])) { // works
if (is_uploaded_file($_FILES[$this->_file]['tmp_name'])) { // File Upload [POST]: Cannot process $_FILES[products_image_resize]['tmp_name']
if (($_FILES[$this->_file]['size'] > 0)) { //works |
Partager