Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
Profolio  
#1 Posted : Monday, March 19, 2012 6:09:28 AM(UTC)
Profolio

Rank: Member

Groups: Member
Joined: 7/9/2008(UTC)
Posts: 20

Hello,
I try this code to upload a file. I do some logs to check where is the pb... but i'ts bizarre. I don't understand.


Code:

require_once ($rel_path."imageuploader/PHP/PHPClasses/ImageUploaderPHP/UploadHandler.class.php");

function saveUploadedFile($uploadedFile) {
        $absGalleryPath = realpath('tmp/') . DIRECTORY_SEPARATOR;
        $convertedFiles = $uploadedFile->getConvertedFiles();
        $sourceFile = $convertedFiles[0];
        $destFolder = $absGalleryPath . $uploadedFile->getRelativePath();
		
		 log_txt('log_upload.txt','absGalleryPath='.$absGalleryPath."\n");	
		 log_txt('log_upload.txt','destFolder='.$destFolder."\n");	
		 
        $relativePath = $uploadedFile->getRelativePath();
		
		 log_txt('log_upload.txt','relativePath='.$relativePath."\n");	
		
        if (!is_dir($destFolder))
        {
            mkdir($destFolder, 0777, true);
			log_txt('log_upload.txt','creation du dossier'."\n");	
        }
			log_txt('log_upload.txt','debut moveto '.$uploadedFile->getSourceName()."\n");	
			log_txt('log_upload.txt','debut moveto '.($destFolder . DIRECTORY_SEPARATOR . rawurlencode($uploadedFile->getSourceName()))."\n");	
			
			$sourceFile->moveTo($destFolder . DIRECTORY_SEPARATOR . rawurlencode($uploadedFile->getSourceName()));
			log_txt('log_upload.txt','fin moveto'."\n");	
    }
    $handler = new UploadHandler();
    $handler->setFileUploadedCallback("saveUploadedFile");
    $handler->processRequest();


/*
try {
  $handler = new UploadHandler();
  $handler->saveFiles("tmp/");
} catch (Exception $e) {
  log_txt('log_upload.txt', $e->getMessage());
}
*/
 log_txt('log_upload.txt','------------------'."\n");



and the log text is
Code:

------------------

absGalleryPath=C:\wamp\www\xxxx\sites\admin\mod\xxx\tmp\

destFolder=C:\wamp\www\xxxx\sites\admin\mod\xxx\tmp\

relativePath=

debut moveto 5101545_n.jpg

debut moveto C:\wamp\www\xxxx\sites\admin\mod\xxx\tmp\\5101545_n.jpg




the file is not created in my tmp dir ...
did you have an idea ?

thanks

Edited by user Thursday, April 12, 2012 7:05:41 AM(UTC)  | Reason: Not specified

Dmitry.Obukhov  
#2 Posted : Monday, March 19, 2012 9:58:59 PM(UTC)
Dmitry.Obukhov

Rank: Advanced Member

Groups:
Joined: 5/29/2010(UTC)
Posts: 1,310

Thanks: 8 times
Was thanked: 111 time(s) in 111 post(s)
Hello Rey,

I checked your code and it works fine – uploaded files were saved to tmp/ folder succesffully. I prepared the simple application based on your server-side script (see upload2.php) and attached it for your reference. Please download zip archive, unpack and deploy the sample on your server.

Then run the uloader and upload some files.
File Attachment(s):
iu7_PHPW.zip (4,525kb) downloaded 8 time(s).
Best regards,
Dmitry Obukhov
Technical Support. Aurigma, Inc.
Profolio  
#3 Posted : Wednesday, March 21, 2012 5:33:44 AM(UTC)
Profolio

Rank: Member

Groups: Member
Joined: 7/9/2008(UTC)
Posts: 20

thanks a lot.
I look ;)

May be it's because of my url's rewriting rules ? is that possible ?
Dmitry.Obukhov  
#4 Posted : Wednesday, March 21, 2012 9:24:51 PM(UTC)
Dmitry.Obukhov

Rank: Advanced Member

Groups:
Joined: 5/29/2010(UTC)
Posts: 1,310

Thanks: 8 times
Was thanked: 111 time(s) in 111 post(s)
Quote:
May be it's because of my url's rewriting rules ? is that possible ?

Unfortunately I cannot answer exactly what causes it. It should be checked and debugged carefully on your end.
Best regards,
Dmitry Obukhov
Technical Support. Aurigma, Inc.
Profolio  
#5 Posted : Friday, April 6, 2012 1:10:50 AM(UTC)
Profolio

Rank: Member

Groups: Member
Joined: 7/9/2008(UTC)
Posts: 20

is there a debug mode with a window to trace the execution of the code (in your java applet)? and how to enable it ?
or is that possible to treat each uploaded file with the $_FILE var in php ?

thanks
Profolio  
#6 Posted : Friday, April 6, 2012 1:37:37 AM(UTC)
Profolio

Rank: Member

Groups: Member
Joined: 7/9/2008(UTC)
Posts: 20

did this command work with abs path ?

$sourceFile->moveTo('c:\tmpz' . DIRECTORY_SEPARATOR . rawurlencode($uploadedFile->getSourceName()));

or only relative paths ?

thanks
Profolio  
#7 Posted : Friday, April 6, 2012 3:16:28 AM(UTC)
Profolio

Rank: Member

Groups: Member
Joined: 7/9/2008(UTC)
Posts: 20

I found something ...
Actually, The $_FILES array is empty in my upload.php script ...
I don't know why ... but there is no files inside ...

in the example you give me the array file is full ...
did you have any idea where it may come ?

thanks
Dmitry.Obukhov  
#8 Posted : Sunday, April 8, 2012 10:27:23 PM(UTC)
Dmitry.Obukhov

Rank: Advanced Member

Groups:
Joined: 5/29/2010(UTC)
Posts: 1,310

Thanks: 8 times
Was thanked: 111 time(s) in 111 post(s)
Hello Rey,

If it is possible could you please provide me with your complete sample application with Image Uploader or complete client-and-server-side scripts at least. It would allow me to test it myself and investigate the problem.
Best regards,
Dmitry Obukhov
Technical Support. Aurigma, Inc.
Profolio  
#9 Posted : Monday, April 9, 2012 1:05:50 AM(UTC)
Profolio

Rank: Member

Groups: Member
Joined: 7/9/2008(UTC)
Posts: 20

hello...
I've tryed some new way. It's a little bit better but my images are not saved :'(
please, find bellow all my source code.

what I would like is to upload some images or folders and recreate the tree of folders with each time a sub folder 'thumb' with thumbnails inside.

code for render the aurigma uploader

Code:


   /* Create Image Uploader */
                  $uploader = new Uploader('Uploader1'); 
                  $uploader->setHeight('650px'); 
                  $uploader->setWidth('100%'); 
				  //Set trial key
                 // $uploader->setLicenseKey('76FF4-00400-0000D-A0ED9-0F8D1-A53B26'); //trial
				  $uploader->setLicenseKey('76FF3-044D2-5FDB0-00090-8DDFF-0D9E0C');
				  
				  $uploader->setScriptsDirectory ('../../../ImageUploader/Scripts');
				  $uploader->getJavaControl()->setCodeBase ('../../../ImageUploader/Scripts/ImageUploader7.jar');
				  $uploader->getActiveXControl()->setCodeBase ('../../../ImageUploader/Scripts/ImageUploader7.cab');

                 
                  //$uploader->getUploadSettings()->setActionUrl('upload2.php');
                    $uploader->getUploadSettings()->setActionUrl('http://'.$_SERVER['HTTP_HOST']."/admin/mod/xxx/up.php");
	
				  $uploader->getUploadSettings()->setFilesPerPackage('1');
				  
                 $uploader->setFolderProcessingMode("Upload");


				  /* Configure converters */
				  //Main converter
  			      $converter1 = new Converter();
                  $converter1->setMode('*.*=Thumbnail');
                  $converter1->setThumbnailWidth(150);
                  $converter1->setThumbnailHeight(150);
				  $converter1->setThumbnailFitMode("Fit");
                  $converter1->setThumbnailApplyCrop(true);
            
				  $uploader->setConverters(
					array(  $converter1  )
				  );

                  require_once ('../imageUploader/PHP/PHPClasses/ImageUploaderPHP/InstallationProgress.class.php'); 
                     
                  $ip = new InstallationProgress($uploader); 
                  $ip->setProgressImageUrl('../../../ImageUploader/PHP/Samples_ImageUploaderJavaScript/Images/installation_progress.gif'); 
                  $ip->setProgressCssClass('ip-progress'); 
                  $ip->setInstructionsCssClass('ip-instructions'); 
                     
                  $uploader->render(); 
				  
				  


and my upload.php code

Code:


<?php
 $rel_path='../../../';
include ($rel_path.'includes/application_top.php');

require_once ($rel_path."imageuploader/PHP/PHPClasses/ImageUploaderPHP/UploadHandler.class.php");
require_once ($rel_path."imageuploader/PHP/Samples_ImageUploaderPHP/Includes/gallery_helper.php");

function displayTree($var) {
     $newline = "\n";
     foreach($var as $key => $value) {
         if (is_array($value) || is_object($value)) {
             $value = $newline . "<ul>" .$key.'='. displayTree($value) . "</ul>";
         }

         if (is_array($var)) {
             if (!stripos($value, "<li class=")) {
                $output .= "\t<li class=\"file\">   " .$key.'='. $value . "    </li>" . $newline;
             }
             else {
                $output .= $value . $newline;
             }
        
         }
         else { // is_object
            if (!stripos($value, "<li class=")) {
               $value = "<ul><li class=\"file\">   " . $value . "   </li></ul>" . $newline;
            }
           
            $output .= "<li class=\"folder\">   " . $key . $value . "   </li>" . $newline;
         }
        
     }
    
     return $output;
}


log_txt('log_upload.txt','post='.displayTree($_POST)."\n");	
/*

log_txt('log_upload.txt','$_FILES='.displayTree($_FILES)."\n");	
log_txt('log_upload.txt','$_SESSION='.displayTree($_SESSION)."\n");	
*/

/*
 
$fileCount = $_POST["PackageFileCount"];
for ($i = 0; $i < $fileCount; $i++) {
    if (isset($_FILES['File0_' . $i])) {
        move_uploaded_file($_FILES['File0_' . $i]['tmp_name'], $path . $_POST['SourceName_' . $i]);
		 log_txt('log_upload.txt','filesname='.$_POST['SourceName_' . $i]."\n");	
    }
}
*/
//This variable specifies relative path to the folder, where the gallery with uploaded files is located.
//Do not forget about the slash in the end of the folder name.
$galleryPath = 'UploadedFiles/';
 
 
/**
 * FileUploaded callback function
 * @param $uploadedFile UploadedFile
 */
function onFileUploaded($uploadedFile) {
  global $galleryPath;
  
  if (!is_dir($galleryPath )) {
    mkdir($galleryPath , 0777);
  }
 
  $absGalleryPath = realpath($galleryPath) . DIRECTORY_SEPARATOR;
  $absThumbnailsPath = $absGalleryPath . 'thumbs'. DIRECTORY_SEPARATOR;
  
	log_txt('log_upload.txt','galleryPath='.$galleryPath."\n");	
	log_txt('log_upload.txt','absGalleryPath='.$absGalleryPath."\n");	
	log_txt('log_upload.txt','absThumbnailsPath='.$absThumbnailsPath."\n");	
	log_txt('log_upload.txt','getPackageIndex='.$uploadedFile->getPackage()->getPackageIndex()."\n");	
	log_txt('log_upload.txt','getPackage='.displayTree($uploadedFile->getPackage())."\n");		
		
 /*
  if ($uploadedFile->getPackage()->getPackageIndex() == 0 && $uploadedFile->getIndex() == 0) {
    initGallery($absGalleryPath, $absThumbnailsPath, FALSE);
  }
 log_txt('log_upload.txt','init=init'."\n");		
	*/
 
   if (!is_dir($absGalleryPath )) {
    mkdir($absGalleryPath , 0777);
  }
   if (!is_dir($absThumbnailsPath)) {
    mkdir($absThumbnailsPath , 0777);
  }
  
  $dirName = $_POST['folder'];
  $dirName = preg_replace('/[^a-z0-9_\-\.()\[\]{}]/i', '_', $dirName);
  

  
  if (!is_dir($absGalleryPath . $dirName)) {
    mkdir($absGalleryPath . $dirName, 0777);
  }
 
  log_txt('log_upload.txt','dirName='.$dirName."\n");	
  
  $path = rtrim($dirName, '/\\') . '/';
 
  $originalFileName = $uploadedFile->getSourceName();
  
   log_txt('log_upload.txt','originalFileName='.$originalFileName."\n");	
  
 
  $files = $uploadedFile->getConvertedFiles();
  
  
    log_txt('log_upload.txt','files='.displayTree($files)."\n");	
  
 
 
  // Save converter 1
  $sourceFile = $files[0];
  
   log_txt('log_upload.txt','sourceFile='.$sourceFile."\n");	
   
  /* @var $sourceFile ConvertedFile */
  if ($sourceFile) {

 
    $sourceFileName = getSafeFileName($absGalleryPath . $path, $originalFileName);
	
	    log_txt('log_upload.txt','sourceFileName='.$sourceFileName."\n");	
		
		
    $sourceFile->moveTo($absGalleryPath . $path . $sourceFileName);
  }
 
 // Save converter2
  $sourceFile = $files[1];
  
   log_txt('log_upload.txt','sourceFile='.$sourceFile."\n");	
  
   
  if ($sourceFile) {
    $sourceFileName = getSafeFileName($absThumbnailsPath, $originalFileName);
	   log_txt('log_upload.txt','sourceFileName='.$sourceFileName."\n");	
    $sourceFile->moveTo($absThumbnailsPath . $sourceFileName);
  }
 /*
  //Load XML file which will keep information about files (image dimensions, description, etc).
  //XML is used solely for brevity. In real-life application most likely you will use database instead.
  $descriptions = new DOMDocument('1.0', 'utf-8');
  $descriptions->load($absGalleryPath . 'files.xml');
 
  //Save file info.
  $xmlFile = $descriptions->createElement('file');
  $xmlFile->setAttribute('name', $_POST['folder'] . '/' . $originalFileName);
  $xmlFile->setAttribute('source', $path . $sourceFileName);
  $xmlFile->setAttribute('description', $uploadedFile->getDescription());
  $xmlFile->setAttribute('size', $uploadedFile->getSourceSize());
  $descriptions->documentElement->appendChild($xmlFile);
  $descriptions->save($absGalleryPath . 'files.xml');*/
}
 
$uh = new UploadHandler();
$uh->setFileUploadedCallback('onFileUploaded');
$uh->processRequest();

?>




an example of the log.txt generated

Code:

post=

post=	<li class="file">   PackageIndex=0    </li>
	<li class="file">   PackageCount=1    </li>
	<li class="file">   PackageGuid={B3A48117-0B58-0E92-D77B-99EC79D11125}    </li>
	<li class="file">   PackageFileCount=1    </li>
	<li class="file">   PHP_SESSIONID=akt6oq4m6houn0kkbjjei1lqg3    </li>
	<li class="file">   SourceName_0=test.jpg    </li>
	<li class="file">   Description_0=    </li>
	<li class="file">   SourceWidth_0=1988    </li>
	<li class="file">   SourceHeight_0=2712    </li>
	<li class="file">   Angle_0=0    </li>
	<li class="file">   HorizontalResolution_0=72    </li>
	<li class="file">   VerticalResolution_0=72    </li>
	<li class="file">   SourceSize_0=980738    </li>
	<li class="file">   CropBounds_0=0,0,1988,2712    </li>
	<li class="file">   Tag_0=    </li>
	<li class="file">   SourceCreatedDateTime_0=    </li>
	<li class="file">   SourceCreatedDateTimeLocal_0=    </li>
	<li class="file">   SourceLastModifiedDateTime_0=2012:01:23 20:48:44    </li>
	<li class="file">   SourceLastModifiedDateTimeLocal_0=2012:01:23 22:48:44    </li>
	<li class="file">   File0Size_0=13892    </li>
	<li class="file">   File0Width_0=110    </li>
	<li class="file">   File0Height_0=150    </li>
	<li class="file">   File0Mode_0=thumbnail    </li>
	<li class="file">   PackageComplete=1    </li>
	<li class="file">   RequestComplete=1    </li>


galleryPath=UploadedFiles/

absGalleryPath=C:\wamp\www\xxx\yyy\admin\mod\xxx\UploadedFiles\

absThumbnailsPath=C:\wamp\www\xxx\yyy\admin\mod\xxx\UploadedFiles\thumbs\

getPackageIndex=0

getPackage=

dirName=

originalFileName=laure_apres3.jpg

files=	<li class="file">   0=
<ul>0=</ul>    </li>



do you see ? the $files is empty ... I don't know why ...
I think the problem is here $uploadedFile->getConvertedFiles();
but i don't know why ...

realy thanks
regards,

Edited by user Thursday, April 12, 2012 7:04:01 AM(UTC)  | Reason: Not specified

Dmitry.Obukhov  
#10 Posted : Monday, April 9, 2012 1:53:10 AM(UTC)
Dmitry.Obukhov

Rank: Advanced Member

Groups:
Joined: 5/29/2010(UTC)
Posts: 1,310

Thanks: 8 times
Was thanked: 111 time(s) in 111 post(s)
I created the sample based on your code and tested it. It works perfectly. I just added the second converter (source file). I attached the sample for your reference. Please download and try it out.
Quote:
what I would like is to upload some images or folders and recreate the tree of folders with each time a sub folder 'thumb' with thumbnails inside.

If I rightly understand, please see this topic. Here you will find the sample application which demonstrates how to upload files/folders and create the same folder structure on the server. You will be able to download and try it out also.

Edited by user Monday, April 9, 2012 1:56:50 AM(UTC)  | Reason: Not specified

File Attachment(s):
iu7_testCode.zip (4,487kb) downloaded 5 time(s).
Best regards,
Dmitry Obukhov
Technical Support. Aurigma, Inc.
Profolio  
#11 Posted : Tuesday, April 10, 2012 1:28:24 AM(UTC)
Profolio

Rank: Member

Groups: Member
Joined: 7/9/2008(UTC)
Posts: 20

AAAHHHH ! I'gonna be crazy :'(
I'm almost sure it's a problem of url rewriting ...

of, course, when I try your demo code, It's working ...
but when I want to include it in my project ... :( :(

I will try to explain exactly my configuration

my folders are like that

[folder]ROOT_SITE
--[folder] admin
----[folder] mod
--------[folder]mymodule
------------[file] index.php
------------[file] include_aurigma.php (included in index.php with include function)
--------[folder] ImageUploader
-----------[folder] ImageUploaderPHP (your folder given in last zip)
-----------[folder] Images (your folder given in last zip)
-----------[folder] Includes(your folder given in last zip)
-----------[folder] Libraries(your folder given in last zip)
----------- .... .... ... (rest of your folder given in last zip)


my url rewriting is something like that

Code:

RewriteCond %{REQUEST_FILENAME} !\.(jar|cab|gif|png|jpg|jpeg|jfif|bmp|css|js|xml|zip|rar|php|html|htm|swf|pdf|doc|docx|xls|xlsx|ppt|pptx)$ [NC]
RewriteRule ^admin/([^/]+)/([^/]+)/([^/]+)$ /admin/index.php?zone=admin&page=$1&page2=$2&page3=$3 [L,NC,QSA]

RewriteCond %{REQUEST_FILENAME} !\.(jar|cab|gif|png|jpg|jpeg|jfif|bmp|css|js|xml|zip|rar|php|html|htm|swf|pdf|doc|docx|xls|xlsx|ppt|pptx)$ [NC]
RewriteRule ^admin/([^/]+)/([^/]+)$ /admin/index.php?zone=admin&page=$1&page2=$2 [L,NC,QSA]

RewriteCond %{REQUEST_FILENAME} !\.(jar|cab|gif|png|jpg|jpeg|jfif|bmp|css|js|xml|zip|rar|php|html|htm|swf|pdf|doc|docx|xls|xlsx|ppt|pptx)$ [NC]
RewriteRule ^admin/([^/]+)$ /admin/index.php?zone=admin&page=$1 [L,NC,QSA]



I try to use absolutes paths, or relative path ...but this is some errors when java load

charger : classe com.aurigma.imageuploader.ImageUploader introuvable.
java.lang.ClassNotFoundException: com.aurigma.imageuploader.ImageUploader
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception : java.lang.ClassNotFoundException: com.aurigma.imageuploader.ImageUploader


my last php code ...
Code:


<?php
    require_once "ImageUploader/ImageUploaderPHP/Uploader.class.php";

 
    /* Create Image Uploader */
    $uploader = new Uploader('Uploader1'); 
    $uploader->setHeight('650px'); 
    $uploader->setWidth('100%'); 
 

    $uploader->getUploadSettings()->setActionUrl('upload.php');
    
     
    $uploader->getUploadSettings()->setFilesPerPackage('1');
                   
    $uploader->setFolderProcessingMode("Upload");
 
 
    /* Configure converters */
    //Main converter
				  
    $converter0 = new Converter();
    $converter0->setMode('*.*=SourceFile');
				  
	$converter1 = new Converter();
	$converter1->setMode('*.*=Thumbnail');
	$converter1->setThumbnailWidth(150);
	$converter1->setThumbnailHeight(150);
	$converter1->setThumbnailFitMode("Fit");
    $converter1->setThumbnailApplyCrop(true);
				  
				  
	$uploader->setConverters(
		array(  $converter0, $converter1  )
	);
 
 $uploader->setScriptsDirectory ('http://'.$_SERVER['HTTP_HOST']."/admin/modules/my_module/ImageUploader/ImageUploaderPHP/Scripts/");
	
	 require_once "ImageUploader/ImageUploaderPHP/InstallationProgress.class.php";  
	$ip = new InstallationProgress($uploader); 
	$ip->setProgressImageUrl('http://'.$_SERVER['HTTP_HOST']."/admin/modules/my_module/ImageUploader/Images/installation_progress.gif"); 
	$ip->setProgressCssClass('ip-progress'); 
	$ip->setInstructionsCssClass('ip-instructions'); 
						  
	$uploader->render(); 
?>
 

Edited by user Thursday, April 12, 2012 7:04:54 AM(UTC)  | Reason: Not specified

Profolio  
#12 Posted : Tuesday, April 10, 2012 2:07:55 AM(UTC)
Profolio

Rank: Member

Groups: Member
Joined: 7/9/2008(UTC)
Posts: 20

It's working !!!!!!!!
OMG !! I don't realy know how... but, I managed that !!!
realy thanks for your help.

best regards

nb : the "remember me function" for your forum don't work ;) lol
Dmitry.Obukhov  
#13 Posted : Tuesday, April 10, 2012 9:11:56 PM(UTC)
Dmitry.Obukhov

Rank: Advanced Member

Groups:
Joined: 5/29/2010(UTC)
Posts: 1,310

Thanks: 8 times
Was thanked: 111 time(s) in 111 post(s)
Hello Rey,

Good to know that you have been resolved this problem :)
Best regards,
Dmitry Obukhov
Technical Support. Aurigma, Inc.
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.