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

Notification

Icon
Error

Options
Go to last post Go to first unread
imanu7  
#1 Posted : Friday, April 27, 2007 4:25:48 AM(UTC)
imanu7

Rank: Member

Groups: Member
Joined: 4/26/2007(UTC)
Posts: 2

Hi, for the first sorry for my english. I install image uploader on my site but when i try to do upload it run correctly but the file that i select not stored in my server

I have an evaluation version for try if it function or not. Please help me!!

this is my javascript:

Code:
<script language="javascript" src="iuembed.js"></script>
<script language="javascript">
var iu = new ImageUploaderWriter("ImageUploader", 730, 550);

// If you do not want to use ActiveX or Java version, set the appropriate
// property to false.
iu.activeXControlEnabled = true;
iu.javaAppletEnabled = true;

iu.activeXControlCodeBase = "ImageUploader4.cab";
iu.javaAppletCodeBase="./";

// ... initialize params as described in the next topic ...

//DISPLAY PANEL 2 COLONNE

//DESTINATION UPLOAD FOLDER
iu.addParam("UploadSourceFile", "true");
iu.addParam("Action", "upload.php");


//QUALITA IMMAGINE
iu.addParam("QualityMeterFormats", "4 x 6,1800,1200,1.5;5 x 7,2100,1500,1.5;" + "8 x 10,3000,2400,1.5;16 x 20,4000,3200,2;30 x 20,6000,4000,2");

//DATI EXIF
iu.addParam("ExtractExif", "ExifDateTime;ExifOrientation;ExifModel");
iu.addParam("UploadThumbnail1FitMode", "Fit");
iu.addParam("UploadThumbnail1Width", "1024");
iu.addParam("UploadThumbnail1Height", "1024");
iu.addParam("UploadThumbnail1JpegQuality", "70");
iu.addParam("UploadThumbnail1CopyExif", "true");

// As soon as you call this method, all necessary HTML code is inserted
// into the page on the current position. Alternatively, you can 
// get the string with appropriate HTML code using the getHtml method,
// and write it to the necessary position manually (maybe with some modifications).  
iu.writeHtml();
</script>

so now i create a new file named upload.php that contain:

<?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/";

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

function saveUploadedFiles()
{
	global $absGalleryPath, $absThumbnailsPath;
	
	//First of all, clear files and data uploaded at previous time.
	
	//Delete source files.
	$handle = opendir($absGalleryPath);

	while (false !== ($file = readdir($handle)))
	{
		if (is_file($absGalleryPath . $file))
		{
			unlink($absGalleryPath . $file);
		}
	}
	closedir($handle); 

	//Delete thumbnails
	$handle = opendir($absThumbnailsPath);	
	while (false !== ($file = readdir($handle))) 
	{
		if (is_file($absThumbnailsPath . $file))
		{
			unlink($absThumbnailsPath . $file);
		}
	}
	closedir($handle);

	//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"];
	
	//Get author name from attached HTML form.
	$author = $_POST ["Author"];
	
	//Iterate through uploaded data and save the original file, thumbnail, and description.
	for ($i = 1; $i <= $fileCount; $i++)
	{
		//Get the first thumbnail (watermarked image) and save it to disk.
		$thumbnail1Field = "Thumbnail1_" . $i;
		if (!$_FILES[$thumbnail1Field]['size'])
		{
			return;	
		}
		$fileName = getSafeFileName(basename($_POST["FileName_" . $i]));		
		copy($_FILES[$thumbnail1Field]['tmp_name'], $absGalleryPath . "/" . $fileName);

		//Get the second thumbnail (small thumbnail) and save it to disk.
		$thumbnail2Field = "Thumbnail2_" . $i;
		if (!$_FILES[$thumbnail2Field]['size'])
		{
			return;	
		}
		copy($_FILES[$thumbnail2Field]['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("author", $author);
		$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();
?>

Edited by user Friday, February 22, 2008 3:02:46 PM(UTC)  | Reason: Not specified

Alex Makhov  
#2 Posted : Friday, May 4, 2007 8:16:28 PM(UTC)
Alex Makhov

Rank: Advanced Member

Groups: Member
Joined: 8/3/2003(UTC)
Posts: 998

Hello,

Please check whether you have configured PHP properly.

Edited by user Monday, October 27, 2008 8:14:33 PM(UTC)  | Reason: Not specified

Sincerely yours,

Alex Makhov

UserPostedImage Follow Aurigma on Twitter!

Users browsing this topic
Guest
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.