2
I created a product register that contains a upload imaging. The operation is being done normally, the file goes to the folder determined, and by the system I can even view the image of which I did the upload.
The problem is when it’s time to change, because when I do the upload by the system, the file goes with access restrictions.
PS: Only when I do upload by the system, because when I copy the file normally by windows, everything is correct and gives no problem at all.
Below is the method of upload:
public static function uploadFile($file, $nomeDocumento, $diretorio, $extValidas = array()) {
$ext = pathinfo ( $file['name'], PATHINFO_EXTENSION );
try {
if (!isset ( $file['error'] ) || is_array( $file['error'] )) {
throw new RuntimeException( 'Parâmetros Inválidos.' );
}
switch ($file['error']){
case UPLOAD_ERR_OK :
break;
case UPLOAD_ERR_NO_FILE :
throw new RuntimeException( 'Nenhum arquivo Enviado.' );
/*
* case UPLOAD_ERR_INI_SIZE:
* case UPLOAD_ERR_FORM_SIZE:
* throw new RuntimeException('Limite de tamanho de arquivo excedido.');
*/
default :
throw new RuntimeException( 'Erro Desconhecido' );
}
// if ($file['size'] > 1000000) { throw new RuntimeException('Limite de tamanho de arquivo excedido.'); }
if (!in_array( $ext, $extValidas )){
throw new RuntimeException( "Formato de arquivo inválido\nArquivos permitidos: " . implode( ', ', array( 'pdf', 'PDF', 'jpg', 'JPG', 'png', 'PNG', 'jpeg', 'JPEG')));
}
if (!move_uploaded_file( $file['tmp_name'], $diretorio . DIRECTORY_SEPARATOR . $nomeDocumento.'.'.$ext)) {
throw new RuntimeException ( 'Failed to move uploaded file.' );
}
return true;
} catch ( RuntimeException $e ) {
return $e->getMessage ();
}
}
P.S.: I am using Yiiframework, and saving the files inside: protected/data/products/.
See the permissions of the folder that is receiving the files! For you this normal pq is the owner! See the others that should solve!
– Ulisses Arrais
I checked and the folder permission is ok, but the problem persists in happening
– Tafarel Brayan