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

Notification

Icon
Error

Options
Go to last post Go to first unread
emile1986  
#1 Posted : Wednesday, January 7, 2009 6:22:16 PM(UTC)
emile1986

Rank: Newbie

Groups: Member
Joined: 11/11/2008(UTC)
Posts: 6

Hello,

I want to use the Image uploader for uploading photo's to multiple photo albums, i already have the dropdown menu sucessfully working, but i don't know how to pass the Album directory to the static 'Gallery' directory.

this is the dropdown menu that i have at this moment:

<?

echo "Album: <select size='1' name='map'>";

$basedir = "../Gallery/"; // read the directory
$n_ext = array('');
if ($handle = @opendir($basedir))
{

$i = 1;
while (false !== ($file = @readdir($handle))) {

if (($file !== ".") and ($file !== "..")) {
$bestand = $basedir ."/". $file ;
$ext = pathinfo($bestand);
if($ext['extension'] == $exten)
{

$mappen[$file] = $file;
$i++;
}
}}
@closedir($handle);
}

sort($mappen);

foreach($mappen as $key => $value){
echo "<option value='". $value ."'>". $value ."</option>";
}
echo "</select>";
?>

anyone any suggestions?
Dmitry  
#2 Posted : Thursday, January 8, 2009 3:40:08 AM(UTC)
Dmitry

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 8/3/2003(UTC)
Posts: 1,070

Thanks: 1 times
Was thanked: 12 time(s) in 12 post(s)
Hello,

You need to write small script that takes the selected value from drop-down menu and passes it to the server using ImageUploader.AddField Method. This trick allows you to pass this value to the server in the same request as files being uploaded. You should extract this value In server upload script and do what you want, for example, create sub-folder in gallery named with the specified name and save files there.

Edited by user Thursday, January 8, 2009 3:41:28 AM(UTC)  | Reason: Not specified

Sincerely yours,
Dmitry Sevostyanov

UserPostedImage Follow Aurigma on Twitter!
emile1986  
#3 Posted : Tuesday, January 13, 2009 7:41:23 PM(UTC)
emile1986

Rank: Newbie

Groups: Member
Joined: 11/11/2008(UTC)
Posts: 6

Ok, i've used the AddField method now, but it isn't working, the images are still uploaded to the static Gallery folder when i have a subfolder selected from the dropdown menu. This is the code i have right now:


<!--BEGIN-->
<!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">
<head>
<title>Aurigma Image Uploader - Basic Demo</title>

<script type="text/javascript" src="../iuembed.js"></script>

</head>
<body>
<p>

<script type="text/javascript">
//<![CDATA[
//Create JavaScript object that will embed Image Uploader to the page.
var iu = new ImageUploaderWriter("ImageUploader1", 770, 500);

//For ActiveX control full path to CAB file (including file name) should be specified.
iu.activeXControlCodeBase = "../ImageUploader5.cab";
iu.activeXControlVersion = "5,7,24,0";

//For Java applet only path to directory with JAR files should be specified (without file name).
iu.javaAppletJarFileName = "ImageUploader5.jar";
iu.javaAppletCodeBase = "../";
iu.javaAppletCached = true;
iu.javaAppletVersion = "5.7.24.0";

iu.showNonemptyResponse = "off";

//Configure appearance.
iu.addParam("PaneLayout", "TwoPanes");
iu.addParam("ShowDebugWindow", "true");
iu.addParam("AllowRotate", "true");
iu.addParam("BackgroundColor", "#ccccff");

//Configure License Keys
iu.addParam("LicenseKey", "71050-4E10B-00000-026F4-59F7B;72050-4E10B-00000-03E16-7B80A");

//Configure thumbnail settings.
iu.addParam("UploadThumbnail1FitMode", "Fit");
iu.addParam("UploadThumbnail1Width", "120");
iu.addParam("UploadThumbnail1Height", "120");
iu.addParam("UploadThumbnail1JpegQuality", "100");

//Configure URL files are uploaded to.
iu.addParam("Action", "upload.php?data1=Select_PhotoAlbum");

function fullPageupload()
{
getImageUploader("ImageUploader1").AddField("Select_PhotoAlbum", "<?php echo $album ?>");
}


//Configure URL where to redirect after upload.
iu.addParam("RedirectUrl", "gallery.php");

//Tell Image Uploader writer object to generate all necessary HTML code to embed
//Image Uploader to the page.
iu.writeHtml();
//]]>
</script><br><br>
<?php

echo "Album: <select size='1' name='map'>";

$basedir = "../Gallery/"; // read the directory
$n_ext = array('');
if ($handle = @opendir($basedir))
{

$i = 1;
while (false !== ($file = @readdir($handle))) {

if (($file !== ".") and ($file !== "..")) {
$bestand = $basedir ."/". $file ;
$ext = pathinfo($bestand);
if($ext['extension'] == $exten)
{

$mappen[$file] = $file;
$i++;
}
}}
@closedir($handle);
}

sort($mappen);

foreach($mappen as $key => $album){
echo "<option value='select_PhotoAlbum'>". $album ."</option>";
}
echo "</select>";
?>
</body>
</html>
<!--END-->

Can some one help me to fix this?

Edited by user Tuesday, January 13, 2009 7:49:36 PM(UTC)  | Reason: Not specified

Tamila  
#4 Posted : Tuesday, January 13, 2009 9:38:34 PM(UTC)
Tamila

Rank: Advanced Member

Groups: Member
Joined: 3/9/2008(UTC)
Posts: 554

Was thanked: 1 time(s) in 1 post(s)
Hello,

It is incorrect use of AddField method. You should write thus:
Code:

var iu = new ImageUploaderWriter("ImageUploader1", 770, 500);

//For ActiveX control full path to CAB file (including file name) should be specified.
iu.activeXControlCodeBase = "../ImageUploader5.cab";
iu.activeXControlVersion = "5,7,24,0";
//... other params

iu.addEventListener("BeforeUpload", "beforeUploadHandler");
//...

iu.writeHtml();

function beforeUploadHandler() {
    getImageUploader("ImageUploader1").AddField("Select_PhotoAlbum", "<?php echo $album ?>");
}


Now you can write something like this:
Code:
$basedir = "../Gallery/" + $_POST["Select_PhotoAlbum"] + "/";
Aurigma Support Team

UserPostedImage Follow Aurigma on Twitter!
emile1986  
#5 Posted : Tuesday, January 13, 2009 11:36:03 PM(UTC)
emile1986

Rank: Newbie

Groups: Member
Joined: 11/11/2008(UTC)
Posts: 6

I have changed my code in the index.php and changed the basedir path in the upload.php file as you said, but it still doesn't work.

When the upload proces is done it said tat it's complete, but the images aren't there when i look in the Gallery folder or in the subfolder i have selected from the dropdown menu as the upload destination.

index.php:
Code:
<!--BEGIN-->
<!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">
<head>
	<title>Aurigma Image Uploader - Basic Demo</title>

	<script type="text/javascript" src="../iuembed.js"></script>

</head>
<body>
	<p>

	<script type="text/javascript">
//<![CDATA[
//Create JavaScript object that will embed Image Uploader to the page.
var iu = new ImageUploaderWriter("ImageUploader1", 770, 500);

//For ActiveX control full path to CAB file (including file name) should be specified.
iu.activeXControlCodeBase = "../ImageUploader5.cab";
iu.activeXControlVersion = "5,7,24,0";

//For Java applet only path to directory with JAR files should be specified (without file name).
iu.javaAppletJarFileName = "ImageUploader5.jar";
iu.javaAppletCodeBase = "../";
iu.javaAppletCached = true;
iu.javaAppletVersion = "5.7.24.0";

iu.showNonemptyResponse = "off";

//Configure appearance.
iu.addParam("PaneLayout", "TwoPanes");
iu.addParam("ShowDebugWindow", "true");
iu.addParam("AllowRotate", "true");
iu.addParam("BackgroundColor", "#ccccff");

//Configure License Keys
iu.addParam("LicenseKey", "71050-4E10B-00000-026F4-59F7B;72050-4E10B-00000-03E16-7B80A");

//Configure thumbnail settings.
iu.addParam("UploadThumbnail1FitMode", "Fit");
iu.addParam("UploadThumbnail1Width", "120");
iu.addParam("UploadThumbnail1Height", "120");
iu.addParam("UploadThumbnail1JpegQuality", "100");

//Configure URL files are uploaded to.
iu.addParam("Action", "upload.php?data1=Select_PhotoAlbum");

//Configure URL where to redirect after upload.
iu.addParam("RedirectUrl", "gallery.php");

[b]iu.addEventListener("BeforeUpload", "beforeUploadHandler");
//...

//Tell Image Uploader writer object to generate all necessary HTML code to embed 
//Image Uploader to the page.
iu.writeHtml();

function beforeUploadHandler() {
    getImageUploader("ImageUploader1").AddField("Select_PhotoAlbum", "<?php echo $album ?>");
}[/b]
//]]>
	</script><br><br>
<?php

echo "Album: <select size='1' name='map'>";

$basedir = "../Gallery/"; // read the directory
$n_ext = array(''); 
if ($handle = @opendir($basedir))
{

$i = 1;
while (false !== ($file = @readdir($handle))) {

if (($file !== ".") and ($file !== "..")) {
$bestand = $basedir ."/". $file ;
$ext = pathinfo($bestand);
if($ext['extension'] == $exten)
{

$mappen[$file] = $file;
$i++;
}
}}
@closedir($handle);
}

sort($mappen);

foreach($mappen as $key => $album){
echo "<option value='select_PhotoAlbum'>". $album ."</option>";
}
echo "</select>";
?>
</body>
</html>
<!--END-->


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 = "../Gallery/" + $_POST["Select_PhotoAlbum"] + "/";
Tamila  
#6 Posted : Wednesday, January 14, 2009 12:45:28 PM(UTC)
Tamila

Rank: Advanced Member

Groups: Member
Joined: 3/9/2008(UTC)
Posts: 554

Was thanked: 1 time(s) in 1 post(s)
I am sorry, it is my fault. According to PHP syntax "." means string concatenation. So you should write thus:
Code:
$galleryPath = "../Gallery/" . $_POST["Select_PhotoAlbum"] . "/";

Aurigma Support Team

UserPostedImage Follow Aurigma on Twitter!
emile1986  
#7 Posted : Wednesday, January 14, 2009 4:48:44 PM(UTC)
emile1986

Rank: Newbie

Groups: Member
Joined: 11/11/2008(UTC)
Posts: 6

I have already changed the + to a . but that also didn't work for me.
Tamila  
#8 Posted : Wednesday, January 14, 2009 5:42:20 PM(UTC)
Tamila

Rank: Advanced Member

Groups: Member
Joined: 3/9/2008(UTC)
Posts: 554

Was thanked: 1 time(s) in 1 post(s)
Could you please post here code of upoad.php file.
Aurigma Support Team

UserPostedImage Follow Aurigma on Twitter!
emile1986  
#9 Posted : Wednesday, January 14, 2009 5:44:21 PM(UTC)
emile1986

Rank: Newbie

Groups: Member
Joined: 11/11/2008(UTC)
Posts: 6

Here is the code of 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 = "../Gallery/" . $_POST["Select_PhotoAlbum"] . "/";

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

function saveUploadedFiles()
{
	global $absGalleryPath, $absThumbnailsPath;

	//NOTE: If you do not want to delete previously uploaded files, just 
	//remove or comment out the code above.
	
	//Create 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');
	$descriptions->appendChild($descriptions->createElement("files"));
	
	//Get total number of uploaded files (all files are uploaded in a single package).
	$fileCount = $_POST ["FileCount"];
	
	//Iterate through uploaded data and save the original file, thumbnail, and description.
	for ($i = 1; $i <= $fileCount; $i++)
	{
		//Get source file and save it to disk.
		$sourceFileField = "SourceFile_" . $i;
		if (!$_FILES[$sourceFileField]['size'])
		{
			return;	
		}
		$fileName = getSafeFileName($_FILES[$sourceFileField]['name']);
		move_uploaded_file($_FILES[$sourceFileField]['tmp_name'], $absGalleryPath . "/" . $fileName);

		//Get first thumbnail (the single thumbnail in this code sample) and save it to disk.
		$thumbnail1Field = "Thumbnail1_" . $i;
		if (!$_FILES[$thumbnail1Field]['size'])
		{
			return;	
		}
		move_uploaded_file($_FILES[$thumbnail1Field]['tmp_name'], $absGalleryPath . "/Thumbnails/" . $fileName . ".jpg");

		//Save file info.
		$xmlFile = $descriptions->createElement("file");
		$xmlFile->setAttribute("name", $fileName);
		$xmlFile->setAttribute("width", $_POST ['Width_' . $i]);
		$xmlFile->setAttribute("height", $_POST ['Height_' . $i]);
		$xmlFile->setAttribute("description", $_POST ['Description_' . $i]);
		$descriptions->documentElement->appendChild($xmlFile);
	}

	$descriptions->save($absGalleryPath . "Descriptions.xml");
}

//This method verifies whether file with such name already exists 
//and if so, construct safe filename name (to avoid collision).	
function getSafeFileName($fileName)
{
	global $absGalleryPath;
	
	$newFileName = $fileName;
	$j = 1;
	while (file_exists($absGalleryPath . "/" . $newFileName))
	{
		$newFileName = $j . "_" . $fileName;
		$j = $j + 1;
	}
	return $newFileName;	
}

saveUploadedFiles();
?>
Tamila  
#10 Posted : Thursday, January 15, 2009 1:29:31 PM(UTC)
Tamila

Rank: Advanced Member

Groups: Member
Joined: 3/9/2008(UTC)
Posts: 554

Was thanked: 1 time(s) in 1 post(s)
Hi,

Thanks for the code. Your upload script works well but your index.php needs some modifications.
Please see the following code, now it works great:

index.php:
Code:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Aurigma Image Uploader - Basic Demo</title>

    <script type="text/javascript" src="iuembed.js"></script>

</head>
<body>
    

    <script type="text/javascript">
//Create JavaScript object that will embed Image Uploader to the page.
var iu = new ImageUploaderWriter("ImageUploader1", 770, 500);

//For ActiveX control full path to CAB file (including file name) should be specified.
iu.activeXControlCodeBase = "ImageUploader5.cab";
iu.activeXControlVersion = "5,7,24,0";

//For Java applet only path to directory with JAR files should be specified (without file name).
iu.javaAppletJarFileName = "ImageUploader5.jar";
iu.javaAppletCodeBase = "./";
iu.javaAppletCached = true;
iu.javaAppletVersion = "5.7.24.0";

iu.showNonemptyResponse = "off";

//Configure appearance.
iu.addParam("PaneLayout", "TwoPanes");
iu.addParam("ShowDebugWindow", "true");
iu.addParam("AllowRotate", "true");
iu.addParam("BackgroundColor", "#ccccff");

//Configure License Keys
iu.addParam("LicenseKey", "71050-4E10B-00000-026F4-59F7B;72050-4E10B-00000-03E16-7B80A");

//Configure thumbnail settings.
iu.addParam("UploadThumbnail1FitMode", "Fit");
iu.addParam("UploadThumbnail1Width", "120");
iu.addParam("UploadThumbnail1Height", "120");
iu.addParam("UploadThumbnail1JpegQuality", "100");

//Configure URL files are uploaded to.
iu.addParam("Action", "upload.php");

//Configure URL where to redirect after upload.
//iu.addParam("RedirectUrl", "gallery.php");

iu.addEventListener("BeforeUpload", "beforeUploadHandler");
//...

//Tell Image Uploader writer object to generate all necessary HTML code to embed
//Image Uploader to the page.
iu.writeHtml();

function beforeUploadHandler() {
	targetFolderValue = document.getElementById("TargetFolder").value;
    getImageUploader("ImageUploader1").AddField("Select_PhotoAlbum", targetFolderValue);
}
    </script><br><br>

<?php
echo "Album:";
echo " <select size='1' name='map' id='TargetFolder'>";

$basedir = "../Gallery/"; // read the directory
$n_ext = array('');

if ($handle = opendir($basedir))
{

$i = 1;
while (false !== ($file = readdir($handle))) {

if (($file !== ".") and ($file !== "..")) {
$bestand = $basedir ."/". $file ;
$ext = pathinfo($bestand);
if($ext['extension'] == $exten)
{

$mappen[$file] = $file;
$i++;
}
}}
closedir($handle);
}

sort($mappen);

foreach($mappen as $key => $album)
{
echo '<option value="'.$album.'">'.$album.'</option>';
}
echo '</select>';
?>
</body>
</html>

I hope it helps you.

Edited by user Thursday, January 15, 2009 1:31:50 PM(UTC)  | Reason: Not specified

Aurigma Support Team

UserPostedImage Follow Aurigma on Twitter!
emile1986  
#11 Posted : Thursday, January 15, 2009 4:32:19 PM(UTC)
emile1986

Rank: Newbie

Groups: Member
Joined: 11/11/2008(UTC)
Posts: 6

Thanks for your help, it is working for me now!
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.