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

Notification

Icon
Error

Options
Go to last post Go to first unread
IRHM73  
#1 Posted : Sunday, February 26, 2012 10:33:21 AM(UTC)
IRHM73

Rank: Member

Groups: Member
Joined: 2/13/2012(UTC)
Posts: 21

Thanks: 1 times
I wonder whether someone may be able to help me please.

I'm slowly building the files that I would like to use to capture and process the images that users will upload to the server.

I'm now looking at saving additional form information, to be precise 'userid' and 'locationname' fields.

I've been working through examples and the documentation but I keep receiving the following error when I run the files:

Quote:
Warning: DOMDocument::load() [domdocument.load]: I/O warning : failed to load external entity "/homepages/2/d333603417/htdocs/development/UploadedFiles/files.xml" in /homepages/2/d333603417/htdocs/development/gallery.php on line 12
I think I'm correct in saying that the problem lies within the 'gallery.php' file, but I've been working on this for a while now and I just can't find the answer.

I just wondered whether someone could perhaps take a look at my files which I've added below:

Many thanks and kind regards

Chris

Index.php

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<?php 
  
  $galleryPath = 'UploadedFiles/';
  $absGalleryPath = realpath($galleryPath) . '/';
  $dirs = array();
  if (file_exists($absGalleryPath . 'files.xml')) {
    $descriptions = new DOMDocument('1.0', 'utf-8');
    $descriptions->load($absGalleryPath . 'files.xml');
    
    for ($i = 0; $i < $descriptions->documentElement->childNodes->length; $i++) {
      $name = $descriptions->documentElement->childNodes->item($i)->getAttribute('name');
      $dir = dirname($name);
      if ($dir && $dir != '.') {
        $dirs[] = array_shift(explode('/', $dir));
      }
    }
    $dirs = array_unique($dirs);
  }
  
?>
<head> 
  <title>Test</title> 
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
  <link href="Styles/style.css" rel="stylesheet" type="text/css" /> 
  <script type="text/javascript" src="Libraries/jquery/jquery-1.4.3.min.js"></script> 
  <script src="Scripts/aurigma.uploader.js" type="text/javascript"></script>
  <script type="text/javascript">
  
  $(function() { 
      var uploaderID = 'Uploader1'; 
      function updateInfo() { 
          var restrictions = $au.uploader(uploaderID).restrictions(); 
          var params = { 
                    enableCmyk: restrictions.enableCmyk() && restrictions.EnableCmyk() !== "false" ? 'True' : 'True', 
                    fileMask: restrictions.fileMask() || '*.*', 
                    maxFileCount: parseInt(restrictions.maxFileCount()) || 'any', 
                    maxFileSize: parseInt(restrictions.maxFileSize()) || 'any', 
                    maxImageHeight: parseInt(restrictions.maxImageHeight()) || 'any', 
                    maxImageWidth: parseInt(restrictions.maxImageWidth()) || 'any'
          }; 
  
          var infoHtml = '<li>Enable CMYK: ${enableCmyk}</li>' + 
          '<li>File mask: ${fileMask}</li>' + 
          '<li>Max file count per upload: ${maxFileCount}</li>' + 
          '<li>Max file size: 1024KB </li>';
  
      infoHtml = infoHtml.replace(/\$\{(\w+)\}/g, function(str0, str1, offset, s) { return params[str1]; }); 
  
      $('#info').html(infoHtml); 
      } 
  
      updateInfo(); 
 
  }); 
    
  </script>

</head> 
<body> 
  <form id="addimages" name="addimages" class="page" action="index.php" method="post" enctype="application/x-www-form-urlencoded"> 
  <label for="userid" class="caption">userid</label>
  <input id="userid" name="userid" type="text"/>
  <label for="locationname" class="caption">locationname</label>
  <input id="locationname" name="locationname" type="text"/>

    <div id="center"> 
      <div class="aB"> 
        <div class="aB-B"> 
		  <?php if ('Uploaded files' != $current['title']) :?>
          <?php endif;?>
          <div class="demo"> 
                <fieldset class="content-block"> 
                  <legend>Restriction settings</legend> 
            <div class="col"> 
                    <div class="row"> 
                      <ul id='info'> 
                      </ul> 
                    </div> 
                  </div> 
                </fieldset> 
                <div class="code">
				 <div class="inner">
              <div class="container">
                <div class="code">
                  <?php
              
                  require_once 'ImageUploaderPHP/Uploader.class.php'; 
                    
                  /* Create Image Uploader */
                  $uploader = new Uploader('Uploader1'); 
                  $uploader->setHeight('370px'); 
                  $uploader->setWidth('100%'); 
                  $uploader->setLicenseKey('XXXXX-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX'); 
				  $uploader->setScriptsDirectory ('ImageUploaderPHP/Scripts');
				  $uploader->getJavaControl()->setCodeBase ('ImageUploaderPHP/Scripts/ImageUploader7.jar');
			      $uploader->getActiveXControl()->setCodeBase ('ImageUploaderPHP/Scripts/ImageUploader7.cab');
 
 				  $uploader->getUploadSettings()->setActionUrl('upload.php');
				  $uploader->getMetadata()->setAdditionalFormName("addimages");
                  $uploader->getUploadSettings()->setRedirectUrl('gallery.php'); 
                 
				  $uploader->getFolderPane()->setHeight(400); 
                  $uploader->getFolderPane()->setViewMode('Tiles');          
                  $uploader->getUploadPane()->setViewMode('Tiles'); 
				  $uploader->getDetailsViewColumns()->setFileNameText('Name');	  
				  		 			  
				  $uploader->getRestrictions()->setFileMask('*.jpg;*.jpeg;*.png;*.bmp;*.gif'); 
                  $uploader->getRestrictions()->setEnableCmyk(true);
				  $uploader->getRestrictions()->setMaxFileCount(10);
				  $uploader->getMessages()->setMaxFileCountExceeded("I'm sorry, the number of files you have selected for this upload session exceed the 10 file limit.");
				  $uploader->getRestrictions()->setMaxTotalFileSize(10485760);
				  $uploader->getMessages()->setMaxTotalFileSizeExceeded("I'm sorry, the number of files that you have selected for this upload session exceed the 10MB limit.");
				  $uploader->getRestrictions()->setMaxFileSize(1048576);
				  $uploader->getRestrictions()->setDeniedFileMask("*.exe;*.bat;*.cmd;*.wsf");
				 
				  $converters = &$uploader->getConverters();
				  $converter = new Converter();
				  $converter->setMode("*.*=Thumbnail");
				  $converter->setThumbnailWidth(700);
				  $converter->setThumbnailHeight(700);
				  $converter->setThumbnailFitMode("Fit");
				  $converter->setThumbnailApplyCrop(true);
				  $converters[] = $converter;
                    
                  require_once 'ImageUploaderPHP/InstallationProgress.class.php'; 
                    
                  $ip = new InstallationProgress($uploader); 
                  $ip->setProgressImageUrl('Images/installation_progress.gif'); 
                  $ip->setProgressCssClass('ip-progress'); 
                  $ip->setInstructionsCssClass('ip-instructions'); 
                    
                  $uploader->render(); 
                  ?>
                </div> 
              </div> 
           	 </div> 
			</div>
		   </div>
		</div>
    </div> 
  </div> 
  </form> 
</body> 
</html>


Upload.php

Code:
<?php

//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/';

require_once 'Includes/gallery_helper.php';

require_once 'ImageUploaderPHP/UploadHandler.class.php';

function saveAllUploadedFiles($uploadedFiles) {
    $packageFields = $uploadedFiles[0]->getPackage()->getPackageFields();
    $userid = $packageFields["userid"];
    $locationname = $packageFields["locationname"];
}

$handler = new UploadHandler();
$handler->setAllFilesUploadedCallback("saveAllUploadedFiles");
$handler->processRequest();
/**
 * FileUploaded callback function
 * @param $uploadedFile UploadedFile
 */
function onFileUploaded($uploadedFile) {
  global $galleryPath;

  $absGalleryPath = realpath($galleryPath) . DIRECTORY_SEPARATOR;
 // $absThumbnailsPath = $absGalleryPath . 'Thumbnails' . DIRECTORY_SEPARATOR;

  if ($uploadedFile->getPackage()->getPackageIndex() == 0 && $uploadedFile->getIndex() == 0) {
    initGallery($absGalleryPath, $absThumbnailsPath);
  }

  $originalFileName = $uploadedFile->getSourceName();

  $files = $uploadedFile->getConvertedFiles();

  // Save source file
  $sourceFile = $files[0];
  /* @var $sourceFile ConvertedFile */
  if ($sourceFile) {
    $sourceFileName = getSafeFileName($absGalleryPath, $originalFileName);
    $sourceFile->moveTo($absGalleryPath . $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', $originalFileName);
  $xmlFile->setAttribute('source', $sourceFileName);
  $xmlFile->setAttribute('description', $uploadedFile->getDescription());
  $descriptions->documentElement->appendChild($xmlFile);
  $descriptions->save($absGalleryPath . 'files.xml');
}

$uh = new UploadHandler();
$uh->setFileUploadedCallback('onFileUploaded');
$uh->processRequest();
?>


Gallery.php

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<?php 

  //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/';
  
  $absGalleryPath = realpath($galleryPath) . DIRECTORY_SEPARATOR;
  
  $descriptions = new DOMDocument('1.0');
  $descriptions->load($absGalleryPath . 'files.xml');
?>
<head>
  <title>Test</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <link href="Styles/style.css" rel="stylesheet" type="text/css" />
  <script type="text/javascript" src="Libraries/jquery/jquery-1.4.3.min.js"></script>
</head>
<body>
  <form id="form1" class="page">
  <div id="container">
    <div id="center">
      <div class="aB">
        <div class="aB-B">
          <?php if ('Uploaded files' != $current['title']) :?>
          <?php endif;?>
          <div class="demo">
            <div class="inner">
              <div class="container">
                <div class="gallery">
                  <ul class="gallery-link-list">
                  <?php for ($i = 0; $i < $descriptions->documentElement->childNodes->length; $i++) :
                          $xmlFile = $descriptions->documentElement->childNodes->item($i);
                  ?>
                  <li><a target="_blank" href="<?php echo $galleryPath . rawurlencode($xmlFile->getAttribute('source')); ?>">
                      <?php echo htmlentities($xmlFile->getAttribute('name'), ENT_COMPAT, 'UTF-8'); ?></a> - 
					  <?php echo htmlentities($xmlFile->getAttribute('description'), ENT_COMPAT, 'UTF-8'); ?></a>
					  </li>
                  <?php endfor; ?>
                  </ul>
                </div>
              </div>
            </div>
          </div>
          <div class="tab-containers">
            <div class="tab-container">
              <div class="tab-inner">
              </div>
            </div>
          </div>
        </div>
        <div class="aB-a">
        </div>
      </div>
    </div>
    <div id="footer"></div>
  </div>
  </form>
</body>
</html>

Edited by user Sunday, February 26, 2012 10:48:22 AM(UTC)  | Reason: Not specified

Dmitry.Obukhov  
#2 Posted : Monday, February 27, 2012 2:41:49 AM(UTC)
Dmitry.Obukhov

Rank: Advanced Member

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

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

I created sample application and attached it for your reference. It illustrates how to send additional fields along with images, get them on server side and use on gallery page. This sample is based on your code with my insignificant updating code. Please download and try it. If you have any questions please post them here – I will assist you willingly.
File Attachment(s):
iu7_PHPSample.zip (4,529kb) downloaded 11 time(s).
Best regards,
Dmitry Obukhov
Technical Support. Aurigma, Inc.
IRHM73  
#3 Posted : Monday, February 27, 2012 3:56:53 AM(UTC)
IRHM73

Rank: Member

Groups: Member
Joined: 2/13/2012(UTC)
Posts: 21

Thanks: 1 times
Hi Dmitry, I have to say I'm blown away with the help you given me through the files that you've sent. They're perfect!

There is one other thing though that I've been working on, which I've been looking through the documentation and the forums for a solution, but I can't seem to find anything.

In the 'gallery' file you sent me, it shows the thumbnails of the uploaded images. Could you tell me please is there anyway of graphically showing folders within the same 'gallery' file?

Once again, sincere thanks and kind regards

Chris

Edited by user Monday, February 27, 2012 10:47:58 AM(UTC)  | Reason: Not specified

Dmitry.Obukhov  
#4 Posted : Monday, February 27, 2012 7:42:55 PM(UTC)
Dmitry.Obukhov

Rank: Advanced Member

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

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

Thank you for your comments :)

Unfortunately, this gallery file is needed to be edited to show folders. Please open Folders Upload Demo-> select PHP platform -> open gallery.php to see code. This sample demonstrates how to implement gallery file to show thumbnails and folders.
Best regards,
Dmitry Obukhov
Technical Support. Aurigma, Inc.
IRHM73  
#5 Posted : Tuesday, February 28, 2012 9:00:43 AM(UTC)
IRHM73

Rank: Member

Groups: Member
Joined: 2/13/2012(UTC)
Posts: 21

Thanks: 1 times
Hi Dmitry,

Many thanks for the confirmation.

Kind regards

Chris
Dmitry.Obukhov  
#6 Posted : Tuesday, March 6, 2012 12:45:14 AM(UTC)
Dmitry.Obukhov

Rank: Advanced Member

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

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

I would like to recommend you to use the second gallery file where all uploaded files (from Thumbnails/ folder) will be showed. Please look at my attached sample.
File Attachment(s):
iu7_ShowAllFiles.zip (4,492kb) downloaded 4 time(s).
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.