Http Error 500 uploadify

Alguem ja viu este erro com uploadify, e poderia me ajudar como solucionar.

Obrigado

qual erro ?

Este HTTP Error 500 quando completa o upload

Sorry, as I do not speak Portugues but that error is normally happening due to the path where you wish to save your archives. Please follow the following steps to make sure everything is ok:

  • Make sure the path to save the archives is correct

  • Make sure the folder is writable

  • Be very carefuly with ‘\’ or ‘/’, use DIRECTORY_SEPARATOR instead

Este esta acão para salvar o arquivo como faço para verificar o path pois nao consigo imprimir na tela para conferir.

Acho que é o path, estou trabalhando com subdominio sera que tem alguma coisa haver.




public function actionUploadedFiles()

        {

                // flash does NOT pass the session

                // thus we pass the id with a $_POST variable




                if (!empty($_FILES)) {

                    $tempFile = $_FILES['Filedata']['tmp_name'];

                    if($_POST['arq']==1){


                        $tempFile = $_FILES['Filedata']['tmp_name'];

                        $targetPath = $_SERVER['DOCUMENT_ROOT'] . 'sitenovo/arquivo_restrito/';

                        $targetFile =  str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];

                    }

                }

}



Estou ficando louco com isso

Ajuda-me

erro 500 significa que tem erro no codigo que você postou, teste fazer upload normal usando form normal com debug ligado e analize o erro




public function actionUploadedFiles()

{

         // flash does NOT pass the session

         // thus we pass the id with a $_POST variable




      if (!empty($_FILES)) {

         $tempFile = $_FILES['Filedata']['tmp_name'];

         if($_POST['arq']==1){


                 $tempFile     = $_FILES['Filedata']['tmp_name'];

                 $targetPath  = $_SERVER['DOCUMENT_ROOT'] . '/sitenovo/arquivo_restrito/'; // You forgot the '/' before sitenovo

                 $targetFile    =  str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];

             // OR

             // $targetPath  = Yii::getPathOfAlias('webroot.arquivo_restrito').DIRECTORY_SEPARATOR;

             //  $targetFile    =  $targetPath . $_FILES['Filedata']['name'];

                      

          }

     }

}



Antônio, como vc resolveu o problema do "Error: HTTP Info: 500" ?

Eu estou utilizando uma extensão do Uploadify aqui também e me ocorreu o mesmo erro.

Sorry, do not speak proper portuguess (forgot all about it when i learnt italian), nevertheless, the problem with http 500 is always a problem of paths or (in case of SWFUpload, session)

The way i solved was with:

  • Make sure the path to save the archives is correct

  • Make sure the folder is writable

  • Be very carefuly with ‘\’ or ‘/’, use DIRECTORY_SEPARATOR instead

  • Make sure you can upload the proper size to the server (2M)

  • Make sure you receive the correct parameter


As gustavo said, TRY TO MAKE A NORMAL POST with the parameters. One good firefox extension to use is the HTTP FILTERs so to check: https://addons.mozilla.org/en-us/firefox/addon/poster/

Follow those steps… and it is true, it was a hard error to find…

Sorry for replying in English

No need to apologize, it’s important that you helped me. My English is not good, is English by google translator

My problem was solved 500 error.

Except that now I have problem in Action within the controller, after uploading this showing the message, upload complete, but my action is not uploading. Does anyone know how to treat this part of the upload in action?

Antonio, how did your action? Thanks…


public function actionUploadedFiles()

    	{

        	

        	if(isset($_POST['PHPSESSID']))

        	{

            	Yii::app()->session->close();

            	Yii::app()->session->sessionID = $_POST['PHPSESSID'];

            	Yii::app()->session->open();

        	}

        	if(Yii::app()->user->isGuest) throw new CHttpException(403,'bad');


        	


        	echo 1;

        	Yii::app()->end();

        	/*

        	if (!empty($_FILES)) {

            	$tempFile = $_FILES['Filedata']['tmp_name'];

            	$targetPath = $_SERVER['DOCUMENT_ROOT'] . '/images/gallery/';

            	$album = $_GET['newFileName'];


            	$ext = substr($_FILES['Filedata']['name'], -3);

            	$folder = $album;

            	$folderPath = $targetPath . $folder;

            	$newFileName = $folder . '.' . $ext;

            	$targetFile =  str_replace('//','/',$targetPath) . $newFileName;

            	mkdir(str_replace('//','/',$folderPath), 0755, true);

            	move_uploaded_file($tempFile,$targetFile);

        	}

        	echo '1';

        	*/

    	}

This was my solution for SWFUpload though, I guess is the same with Uploadify:

on index.php




if (isset($_POST['PHPSESSID']))

{

  $_COOKIE['PHPSESSID'] = $_POST['PHPSESSID'];

}



The upload function





try{

			$picture_file = CUploadedFile::getInstanceByName('Filedata');

			

			if(!$picture_file || $picture_file->getHasError()){

				echo 'Error: Documento Invalido'; 

				Yii::app()->end();

			}

			

			$newsId = Yii::app()->request->getParam('newsId');

			// this function was to validate the picture --- my own

			$result = Picture::validateUploadedPicture($picture_file,1480,1240,240,180,array('image/jpeg','image/gif','image/png'));

		

                       // was too lazy to write a different Exception Class 

			switch($result){

				case Picture::MAX_HEIGHT_ERROR:

					throw new Exception('Maximum allowed height is 1240px');

					break;

				case Picture::MAX_WIDTH_ERROR:

					throw new Exception('Maximum allowed width is 1480px');

					break;

				case Picture::MIN_HEIGHT_ERROR:

					throw new Exception('Minimum allowed height is 240px');

					break;

				case Picture::MIN_WIDTH_ERROR:

					throw new Exception('Minimim allowed width is 180px');

					break;

				case Picture::MIME_TYPE_ERROR:

					throw new Exception('JPEG, GIF and PNG are the only MIME TYPES allowed');

					break;

				

			}

			

			$picture_name = Picture::createPictureName($picture_file->name);	

			

                        // I used the good PhpThumb library to resize and save appropiately

			$thumbFactory = PhpThumbFactory::create($picture_file->getTempName());

			

			$thumbFactory->adaptiveResize(40,40)->save(Yii::getPathOfAlias('webroot.images.gallery.thumbs') .'/'. $picture_name);

			

			$picture_file->saveAs(Yii::getPathOfAlias('webroot.images.gallery') . '/' . $picture_name);

			

			

			$pic = new Picture();

			$pic->name = $picture_name;

			$pic->newsId = $newsId;

			$pic->save();

			

			

			// return the message to SWFUpload 

			echo "FILEID:" . Yii::app()->getBaseUrl() . '/images/gallery/thumbs/' . $picture_name . '?'.$newsId;	// Return the file id to the script




If you wish to have a look at the validation of a picture function




public static function validateUploadedPicture( CUploadedFile $file, $maxWidth, $maxHeight, $minWidth, $minHeight, $mimeTypes ){

		

		$info = @getimagesize( $file->getTempName() );

		

		// remove unnecessary values from $info and make it more readable

		$info = array(

			'width' => $info[0],

			'height' => $info[1],

			'mime' => $info['mime'],

		);

		

		if ($info['width'] < $minWidth) {

			return self::MIN_WIDTH_ERROR;

		}

		if ($info['width'] > $maxWidth) {

			return self::MAX_WIDTH_ERROR;	

		}

		if ($info['height'] < $minHeight) {

			return self::MIN_HEIGHT_ERROR;

		}

		if ($info['height'] > $maxHeight) {

			return self::MAX_HEIGHT_ERROR;

		}

		

		$mimeTypes = is_scalar($mimeTypes) ? array($mimeTypes) : $mimeTypes;

		if (!in_array($info['mime'], $mimeTypes)) {

			return self::MIME_TYPE_ERROR;

		}

		return self::PICTURE_VALID;

		

	}




Have a look at my article: http://www.ramirezcobos.com/2010/11/06/how-to-use-swfuploads-yii-extension/

Cheers

Valeu, consegui resolver. mas fiz de outra forma usando o outro mesmo.

Hi Breno,

Would be nice if you post that solution here for that as it is a common problem for flash uploaders.

in view:




<div class="row">

    	<?php

    	$this->widget('application.extensions.uploadify.EuploadifyWidget',

        	array(

            	'name'=>'uploadme',

            	'options'=> array(

                	//'uploader' => '/js/uploadify.swf',

                	'script' => $this->createUrl('ata/UploadedFiles'),

                	'cancelImg' => '../../images/cancel.png',

                	'auto' => true,

                	'multi' => true,

                	'folder' => '../../images/uploads/',

                	'scriptData' => array('extraVar' => 1234, 'PHPSESSID' => session_id()),

                	//'fileDesc' => 'Declaratiebestanden',

                	//'fileExt' => '*.*',

                	'buttonText' => 'Enviar arquivo',

                	'buttonImg' => '../../images/upload.gif',

                	'width' => 30,

                	'height' => 30,

                	),

            	'callbacks' => array(

               	'onError' => 'function(evt,queueId,fileObj,errorObj){alert("Error: " + errorObj.type + "\nInfo: " + errorObj.info);}',

               	'onComplete' => 'function(){alert("Upload Completo");}',

               	'onCancel' => 'function(evt,queueId,fileObj,data){alert("Upload Cancelado");}',

            	)

        	));

    	?>

    	</div>



in controller:




public function actionUploadedFiles()

    	{

                	if(isset($_POST['PHPSESSID']))

                	{

                    	Yii::app()->session->close();

                    	Yii::app()->session->sessionID = $_POST['PHPSESSID'];

                    	Yii::app()->session->open();

                	}

                	if(Yii::app()->user->isGuest) throw new CHttpException(403,'bad');


                	if (!empty($_FILES)) {

                    	$tempFile = $_FILES['Filedata']['tmp_name'];

                    	$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';

                    	$targetFile =  str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];


                    	// $fileTypes  = str_replace('*.','',$_REQUEST['fileext']);

                    	// $fileTypes  = str_replace(';','|',$fileTypes);

                    	// $typesArray = split('\|',$fileTypes);

                    	// $fileParts  = pathinfo($_FILES['Filedata']['name']);


                    	// if (in_array($fileParts['extension'],$typesArray)) {

                            	// Uncomment the following line if you want to make the directory if it doesn't exist

                            	// mkdir(str_replace('//','/',$targetPath), 0755, true);


                            	move_uploaded_file($tempFile,$targetFile);

                            	echo "1";

                    	// } else {

                    	// 	echo 'Invalid file type.';

                    	// }

                	}


                	echo 1;

                	Yii::app()->end();

    	}



REMEMBER TO NOT TO CONFLICT UPLOADIFY URLS WITH CONTROLLER URLS, i.e image/producer will conflict with producer controller actions

pra quem interessar, fiz uma extensão do uploadify já que as outras que procurei eram de 2009 e não me pareceram boas de usar

na página da extensão explica como usar

Abraço,

Gustavo