Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7785925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:20:02+00:00 2026-06-01T20:20:02+00:00

I wonder whether someone may be able to help me please. Using Aurigma image

  • 0

I wonder whether someone may be able to help me please.

Using Aurigma image Uploader I’ve put together the code below which allows users to upload location based images.

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

/**
 * FileUploaded callback function
 * @param $uploadedFile UploadedFile
 */
function onFileUploaded($uploadedFile) {

  $packageFields = $uploadedFile->getPackage()->getPackageFields();
  $username=$packageFields["username"];
  $locationid=$packageFields["locationid"];

  global $galleryPath;

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

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

  $locationfolder = $_POST['locationid'];
  $locationfolder = preg_replace('/[^a-z0-9_\-\.()\[\]{}]/i', '_', $locationfolder);
  if (!is_dir($absGalleryPath . $locationfolder)) {
    mkdir($absGalleryPath . $locationfolder, 0777);
  }

  $dirName = $_POST['folder'];
  $dirName = preg_replace('/[^a-z0-9_\-\.()\[\]{}]/i', '_', $dirName);
  if (!is_dir($absGalleryPath . $dirName)) {
    mkdir($absGalleryPath . $dirName, 0777);
  }

  $path = rtrim($dirName, '/\\') . '/';

  $originalFileName = $uploadedFile->getSourceName();

  $files = $uploadedFile->getConvertedFiles();

  // save converter 1

  $sourceFileName = getSafeFileName($absGalleryPath, $originalFileName);
  $sourceFile = $files[0];
  /* @var $sourceFile ConvertedFile */
  if ($sourceFile) {
    $sourceFile->moveTo($absGalleryPath . $sourceFileName);
  }

  // save converter 2   

  $thumbnailFileName = getSafeFileName($absThumbnailsPath, $originalFileName);
  $thumbnailFile = $files[1];
  /* @var $thumbnailFile ConvertedFile */
  if ($thumbnailFile) {
    $thumbnailFile->moveTo($absThumbnailsPath . $thumbnailFileName);
  }

  //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', $sourceFileName);
  $xmlFile->setAttribute('size', $uploadedFile->getSourceSize());
  $xmlFile->setAttribute('originalname', $originalFileName);
  $xmlFile->setAttribute('thumbnail', $thumbnailFileName);
  $xmlFile->setAttribute('description', $uploadedFile->getDescription());
  //Add additional fields
  $xmlFile->setAttribute('username', $username);
  $xmlFile->setAttribute('locationid', $locationid);
  $xmlFile->setAttribute('folder', $dirName);
  $descriptions->documentElement->appendChild($xmlFile);
  $descriptions->save($absGalleryPath . 'files.xml');
}

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

This code, in addition to the original script creates a ‘location’ folder with it’s name derived from the ‘locationid’ value.

I’ve now come across a problem which I just can’t seem to find the solution to.

When the user adds an image, the original image, a file entitled ‘files.xml’ and a folder called Thumbnails containing a thumbnail version of the image are created and saved in a folder called ‘UploadedFiles’.

What I’m trying to do is to move the afore mentioned files into my ‘location’ folder, so the structure would be:

Uploaded Files (Folder)

  • Location (subfolder), containing original image, ‘files.xml’, Thumbnails folder containing and thumbnail image

I’m certainly not an expert in PHP, but I’ve tried to follow the format of the existing code creating:

$locationpath = $locationfolder
$abslocationpath = realpath($locationpath) . DIRECTORY_SEPARATOR;

I then tried to point the various files and folders I want to move to $abslocationpath but this doesn’t work. I’m sure that the answer lies within creating a new directory, but I’m at a loss about how to do this.

I just wondered whether someone could perhaps provide some guidance please on how I can create the relevant directory and move the files to the new folder structure I want to create.

Many thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T20:20:03+00:00Added an answer on June 1, 2026 at 8:20 pm

    Your code looks fine, however, I don’t see where you make any calls that actually move anything to the locations path.

    I’ve modified your code slightly. Please first look through it, paying attention to the commented lines and make adjustments accordingly and let me know if it produces the desired results:

    require_once 'Includes/gallery_helper.php';
    require_once 'ImageUploaderPHP/UploadHandler.class.php';
    $galleryPath = 'UploadedFiles/';
    
    function onFileUploaded($uploadedFile) {
      global $galleryPath;
    
      $packageFields = $uploadedFile->getPackage()->getPackageFields();
      $username=$packageFields["username"];
      $locationid=$packageFields["locationid"];
      $locationfolder = preg_replace('/[^a-z0-9_\-\.()\[\]{}]/i', '_', $_POST['locationid']);
      $dirName = preg_replace('/[^a-z0-9_\-\.()\[\]{}]/i', '_', $_POST['folder']);
    
      $absGalleryPath = realpath($galleryPath) . DIRECTORY_SEPARATOR . $locationfolder . DIRECTORY_SEPARATOR;
      $absThumbnailsPath = $absGalleryPath . 'Thumbnails' . DIRECTORY_SEPARATOR;
    
      if (!is_dir($absGalleryPath)) mkdir($absGalleryPath, 0777, true);
      chmod($absGalleryPath, 0777);
      if (!is_dir($absGalleryPath . $dirName)) mkdir($absGalleryPath . $dirName, 0777, true);
      chmod($absGalleryPath . $dirName, 0777);
    
      if ($uploadedFile->getPackage()->getPackageIndex() == 0 && $uploadedFile->getIndex() == 0)
        initGallery($absGalleryPath, $absThumbnailsPath, FALSE);
    
      $originalFileName = $uploadedFile->getSourceName();
      $files = $uploadedFile->getConvertedFiles();
      $sourceFileName = getSafeFileName($absGalleryPath, $originalFileName);
      $sourceFile = $files[0];
    
      if ($sourceFile) $sourceFile->moveTo($absGalleryPath . $sourceFileName);
      $thumbnailFileName = getSafeFileName($absThumbnailsPath, $originalFileName);
      $thumbnailFile = $files[1];
      if ($thumbnailFile) $thumbnailFile->moveTo($absThumbnailsPath . $thumbnailFileName);
    
      $xmlFile = $descriptions->createElement('file');
      // <-- please check the following line
      $xmlFile->setAttribute('name', $_POST['folder'] . '/' . $originalFileName);
      $xmlFile->setAttribute('source', $sourceFileName);
      $xmlFile->setAttribute('size', $uploadedFile->getSourceSize());
      $xmlFile->setAttribute('originalname', $originalFileName);
      $xmlFile->setAttribute('thumbnail', $thumbnailFileName);
      $xmlFile->setAttribute('description', $uploadedFile->getDescription());
      $xmlFile->setAttribute('username', $username);
      $xmlFile->setAttribute('locationid', $locationid);
      $xmlFile->setAttribute('folder', $dirName);
    
      $descriptions = new DOMDocument('1.0', 'utf-8');
      $descriptions->load($absGalleryPath . 'files.xml');
      $descriptions->documentElement->appendChild($xmlFile);
      $descriptions->save($absGalleryPath . 'files.xml');
    }
    
    $uh = new UploadHandler();
    $uh->setFileUploadedCallback('onFileUploaded');
    $uh->processRequest();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wonder whether someone may be able to help me please. I'm using Aurigma
I wonder whether someone could help me please. I'm using Image Uploader from Aurigma,
I wonder whether someone may be able to help me please. I've put together
I wonder whether someone may be able to help me please. I'm using Aurigma's
I wonder whether someone may be able to help me please. I've put together
I wonder whether someone may be able to help me please. I've put together
I wonder whether someone may be able to help me please. I've put together
I wonder whether someone may be able to help me please. Using some excellent
I wonder whether someone may be able to help me please. I'm using the
I wonder whether someone may be able to help please. I'm using the script

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.