Re: Pass uploaded filename to an XML file

See all posts Reply

Re: Pass uploaded filename to an XML file new!
by Top, 10 years, 7 months ago
I need a little guidance on how to pass the uploaded filename to an XML file. I have everything working properly to get the image files and modified image files to the directories they need to be in. I am struggling on how to pass the image filenames into an XML file. I want to use that XML file to populate an image gallery of the uploaded files. Any assistance is greatly appreciated...Reply
Re: Pass uploaded filename to an XML file new!
by Top, 10 years, 7 months ago
I'm using the following code to copy the images to the necessary directories and to edit the xml file I want to edit with the uploaded filenames. If someone could give me some insight on how to use one of the post-processing variables to pass their values to the xml file wold be greatly appreciated.

include('class.upload.php');
$filehandler = new upload($_FILES['image_field']);
if ($filehandler->uploaded) {
  // save uploaded image with no changes
  $filehandler->file_overwrite = true;
  
  $filehandler->Process('load/images/');
  if ($filehandler->processed) {
    echo 'original image copied';
  } else {
    echo 'error : ' . $filehandler->error;
  }
  
  // save uploaded image with a new name,
  // resized to 160px height
  // $filehandler->file_new_name_body = 'image_resized';
  //$filehandler->image_convert = jpg;
  $filehandler->image_resize = true;
  $filehandler->file_overwrite = true;  
  $filehandler->image_y = 160;
  $filehandler->image_ratio_x = true;
  
  $filehandler->Process('load/thumbs/');
 
  if ($filehandler->processed) {
    echo 'image renamed, resized y=160
          and converted to JPG';
    $filehandler->Clean();
  } else {
    echo 'error : ' . $filehandler->error;
  }
}

$thumbimage = array(
	'thumbnail' => 'Thumbnail file name from class.upload.php',);
	
$fullimage = array(
	'imageload' => 'Full image file name from class.upload.php',);
	
$imagetext = array(
//Can still use description parameter from form in index php file
    'description' => $_POST['description_text'],);
    
$doc = new DOMDocument();
$doc->load( 'load/config.xml' );

$doc->formatOutput = true;
$r = $doc->getElementsByTagName("settings")->item(0);

$b = $doc->createElement("image");

$thumb_path = $doc->createElement("thumb_path");
$thumb_path->appendChild(
    $doc->createTextNode( $thumbimage["thumbnail"] )
);
$b->appendChild( $thumb_path );


$big_image_path = $doc->createElement("big_image_path");
$big_image_path->appendChild(
    $doc->createTextNode( $fullimage["imageload"] )
);
$b->appendChild( $big_image_path );


$description_text = $doc->createElement("description_text");
$description_text->appendChild(
    $doc->createTextNode( $imagetext["description"])
);

$b->appendChild( $description_text );

$r->appendChild( $b );

$doc->save("load/config.xml"); 


The XML file parmeters should look like this:

		load/thumbs/18.jpg
		load/images/18.jpg
		Dog Image

The code I currently have produces this:


Thumbnail file name from class.upload.phpFull image file name from class.upload.phpGirls
Reply
Re: Pass uploaded filename to an XML file new!
by colin, 10 years, 7 months ago
Look in the docs for file_dst_name and file_dst_pathnameReply