Page 1 of 1

ok, my brain is fried...

Posted: Mon Jul 25, 2005 1:48 am
by sounder
It’s 2:30 in the morning and I don't even know what I am looking at anymore. So I need some pointers.
What I want to accomplish: I want a flash movie that displays featured property for a real estate project I am working on. What is needed in the movie is the jpg of the house, price, sq foot, bedrooms, bathrooms, description, and agent. Now I have a db with all the text stuff in it, and have successfully pushed the data into flash using asp. I can not figure the picture part. I can pull the data location from the access db into flash but I do not know how to display the image. The image has to have a relationship with the data, so that every 7 sec the next record is faded in with the image. Also I can’t figure out how to get the flash movie to process the records over time.

Also, I need a PHP page to be able to update this information. I have a tutorial for uploading images to a database, but I need to study it further. Basically something that can edit and modify and delete the records in the database. I have lost my mind in this endeavor. I might need a few days away from it to understand it fully. But if anyone can help with any portion of this project would be awesome!!

Where I need help the most is getting the jpg into flash, and the PHP Admin page that will facilitate control over this content. I would like to keep all the data in the db, and have an images folder and use PHP page to upload a given file and update the properties and so forth. Anyone been there, done that and even got the T-shirt??

Regards,
Corey

Posted: Mon Jul 25, 2005 1:59 am
by s.dot
I wrote a tutorial for uploading images, but it uploads it to the server instead of the database.

Here's a look at that, in full context
----------------------------------------
Uploading images!

Here we are going to work with uploading an image through a form on a webpage.
This is easily one of the most requested and confusing scripts. In actuality
it is quite easy. I will walk you through uploading images using the script
below which will allow you to:

1. Choose the directory you wish for images to be uploaded to.
2. Check for common uploading errors.
3. Restrict certain types of files from being uploaded.
4. Set a size limit.
5. View the image once it's been uploaded.

Code: Select all

<?
// We will check to see if an image is attempting to be uploaded
if($_POSTї'action'] == &quote;uploadimage&quote;)
{
	/* $uploaddir should be set to the relative path that you wish for your
	uploaded images to go to.
  The path must end in a slash (/) and must be
	set to CHMOD 0777. */
	$uploaddir = &quote;path/to/dir/&quote;;

	/* Now we will check to see if the path you specified for uploads exists
	and if it has the proper permissions (CHMOD) */
	if(!is_dir($uploaddir))
	{
		die(&quote;The path specified for uploads ( <B>$uploaddir</B> )does not exist.  Please check your upload directory path.&quote;);
	}
	if(!is_writable($uploaddir))
	{
		die(&quote;Your upload directory ( <B>$uploaddir</B> ) does not have the proper permissions set.  To upload files set your upload directory to CHMOD 0777&quote;);
		/* In most FTP programs you can right click on the directory name and change
		the read/write/execute permissions.  To do it in PHP take a look at the chmod()
		function at http://us3.php.net/manual/en/function.chmod.php */
	}

	/* Now we will set a variable to represent the maximum allowed file size.  Make a
	note that file sizes are measured in bytes.  If you do not wish to have a file limit,
	set this variable to an extremely high number, or remove it, and the check against
	the file size of the file being uploaded below.  For this example we'll use a 1 MB
	file size limit. */

	$max_size = 1024000;


	// Check to see that a file is being uploaded

	if(is_uploaded_file($_FILESї'filetoupload']ї'tmp_name']))
	{
		// Get the size of the image being uploaded
		$size = $_FILESї'filetoupload']ї'size'];
	
		// Check to see if the image size is greater than our set $max_size	

		if($size > $max_size)
		{
			die(&quote;Your image is too large.&quote;);
		}
	
		// Store the filename in a variable
		$filename = $_FILESї'filetoupload']ї'name'];
	
		// Get the extention of the filename

		$extension = strtolower(strrchr($filename,&quote;.&quote;));
	
		// We're going to set an array for the ALLOWED extensions

		$allowed_extensions = array('.jpg','.jpeg','.gif','.bmp');
	
		// Next we'll make sure that the image being uploaded does in fact have one of the extensions listed above

		if(!in_array($extension, $allowed_extensions))
		{
			die(&quote;The file type you have attempted to upload is not allowed.&quote;);
		}
	
		/* This next line is a matter of personal preference, but I like to have all images uploaded
		have a random name.  This helps insure that two files never have the same name, and that special
		characters aren't put into the filename.  For most purposes time() will work well. */
		$time = time();

		
		// Set our desired filename equal to $time + the image extention
		$desiredfilename = $time.$extension;
	
		// Next we will move our temporary uploaded image into a permanent position on the web server.

		if(move_uploaded_file($_FILESї'filetoupload']ї'tmp_name'],$uploaddir.$desiredfilename))
		{

			echo &quote;SUCCESS!  Your image has been successfully uploaded!  You can look at it here: <a href=\&quote;$uploaddir$desiredfilename\&quote;>$uploaddir$desiredfilename</a>.&quote;;
		} ELSE
		{

			echo &quote;EEK!  Something went wrong, please consult your system administrator.&quote;;
		}
	}
}

// Finally, comes our HTML form
?>

<!DOCTYPE HTML PUBLIC &quote;-//W3C//DTD HTML 4.01 Transitional//EN&quote;>
<HTML>
	<HEAD>
		<TITLE>Image Uploads</TITLE>
	</HEAD>
<BODY>
<h4>Upload your image!</h4>
<FORM ACTION=&quote;<? echo $_SERVERї'PHP_SELF']; ?>&quote; METHOD=&quote;post&quote; ENCTYPE=&quote;multipart/form-data&quote;>
<INPUT TYPE=&quote;hidden&quote; NAME=&quote;action&quote; VALUE=&quote;uploadimage&quote;>
<INPUT TYPE=&quote;file&quote; NAME=&quote;filetoupload&quote;>
<INPUT TYPE=&quote;submit&quote; VALUE=&quote;Upload!&quote;>
</FORM>

</BODY>
</HTML>
It is worth being noted that this script could be easily modified to upload any type of file.
Simply change the allowed extensions, or remove that line and the check for extensions from the
script.

Happy uploading!
--------------------------------------
end tutorial.

Posted: Thu Aug 04, 2005 1:20 pm
by rosslad2004
Many thanks for the tutorial

It has helped me out big time :D

Kind Regards
Ross