RESOLVIDO: Bloquear upload imagem > q 50kb no frontepage

  • janaina.lima
  • Avatar de janaina.lima Autor do Tópico
  • Offline
  • JCB! Novato
  • JCB! Novato
Mais
14 anos 1 mês atrás #55025 por janaina.lima
janaina.lima created the topic: RESOLVIDO: Bloquear upload imagem > q 50kb no frontepage
Preciso de ajuda!

Estou alterando o componente frontpage slideshow para que ao adicionar uma imagem que já esteja no servidor ele não permita salvar uma imagem maior que 50 kb.

Para fazer o upload da máquina do usuário o seguinte código resolveu:
if($imageaction==2) { // if action is to upload image

		if($_FILES&#91;'image'&#93;&#91;'size'&#93;<=51200) { // if is selected an image 
		
			if(!$image = mosFPSlideShow::uploadMedia($_FILES, 'image', $option, "", $width, $quality)) { // if the image is uploaded				
				$msg = _FPSS_UPLOAD_FAIL7;
				$mainframe->redirect( 'index.php?option='.$option.'&task=slides&filter_catid='.$row->catid.'&limit='.$limit.'&limitstart='.$limitstart, $msg );
			}// $image the new path of the image			
		}else{
				$teste = $_FILES&#91;'image'&#93;&#91;'size'&#93;;
				$msg = _FPSS_SLIDE_SIZE_IMAGE;
				$mainframe->redirect( 'index.php?option='.$option.'&task=slides&filter_catid='.$row->catid.'&limit='.$limit.'&limitstart='.$limitstart, $msg );

Mas não consigo o mesmo para imagens que já estão no servidor do joomla, o que estou fazendo de errado?
} 	} elseif($imageaction==3)  { // if the action is an image on the server

		// get the complete abs path
		$abspath = str_replace($mosConfig_live_site,$mosConfig_absolute_path,$serverimage);

		if($_FILES&#91;'image'&#93;&#91;'size'&#93;<=51200){ 
			if(is_file($abspath)) { // if is selected an image
			if(!$image = mosFPSlideShow::uploadMediaServer($abspath, 'image', $option, "", $width, $quality)) { // if the image is uploaded
				$teste = $_FILES&#91;'image'&#93;&#91;'size'&#93;;			
				$msg = _FPSS_SLIDE_SIZE_IMAGE;;
			}else{
				$mainframe->redirect( 'index.php?option='.$option.'&task=slides&filter_catid='.$row->catid.'&limit='.$limit.'&limitstart='.$limitstart, $msg );
				$msg = _FPSS_UPLOAD_FAIL7;


			}

Please Entrar ou Registrar to join the conversation.


  • janaina.lima
  • Avatar de janaina.lima Autor do Tópico
  • Offline
  • JCB! Novato
  • JCB! Novato
Mais
14 anos 1 mês atrás #55069 por janaina.lima
janaina.lima replied the topic: Re: Bloquear upload de imagem maior que 50kb no frontepage slids
Resolvido: <!-- s:ok: --><img src="{SMILIES_PATH}/ok.gif" alt=":ok:" title="Ok" /><!-- s:ok: -->

É uma pena ninguém ter se proposto a ajudar... a troca de conhecimento ajudaria a muitos.

Por isso, coloco a solução encontrada por um amigo.

} elseif($imageaction==3) { // if the action is an image on the server

		// get the complete abs path
		$abspath = str_replace($mosConfig_live_site,$mosConfig_absolute_path,$serverimage);
		if(is_file($abspath)) { // if is selected an image

			//Condição de tamanho
			
			&#91;b&#93;if(filesize($abspath) >=51200) { // if the image is uploaded
				$msg = _FPSS_SLIDE_SIZE_IMAGE;&#91;/b&#93;
				$mainframe->redirect( 'index.php?option='.$option.'&task=slides&filter_catid='.$row->catid.'&limit='.$limit.'&limitstart='.$limitstart, $msg );
				// $image the new path of the image
			}

			if(!$image = mosFPSlideShow::uploadMediaServer($abspath, 'image', $option, "", $width, $quality)) { // if the image is uploaded
				$msg = _FPSS_UPLOAD_FAIL3;
				$mainframe->redirect( 'index.php?option='.$option.'&task=slides&filter_catid='.$row->catid.'&limit='.$limit.'&limitstart='.$limitstart, $msg );
				// $image the new path of the image
			}

Please Entrar ou Registrar to join the conversation.