Page 1 of 1

file upload question

Posted: Mon Sep 05, 2005 3:32 pm
by carlos selector
My knowledge of php is very limited, basically I only ever use it to pass stuff from mysql to flash. I am trying to upload images via flash into a folder as well as into a database. I can send a variable of the file to be uploaded from flash to php in the form "C:\example\the_file.jpg" but I don't know how to then upload it. Here is my <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span> code with no error handling...

Code: Select all

<?php
$url_path = "gallery/"; //This variable will be passed from flash
$users_file = "D:\doc.txt"; //This variable will be passed from flash
$name = "test" //This variable will be passed from flash

$doc_directory = "/var/www/html/the_folder/";
$my_file = $url_path.$users_file;
$copy_path = $doc_directory.$my_file;



		move_uploaded_file($users_file, $copy_path);
		
		printf ($copy_path);
	
	
  $db = mysql_connect("localhost", "root", "password");

  		mysql_select_db("the_db",$db);

  		$sql = "INSERT INTO the_table (file, name) VALUES ('$users_file', '$name')";

  		$result = mysql_query($sql);
  		
  		
?>
any help converting $users_file into something uploadable would be greatly appreciated. The database side of things works fine.

Posted: Mon Sep 05, 2005 3:43 pm
by josh
I don't think flash allows you to have a file input field, at least not with flash 5 / the first mx. What you might have to do is let the users upload from an html form to upload


http://us3.php.net/features.file-upload

Posted: Mon Sep 05, 2005 9:50 pm
by carlos selector
In theory you're right, flash doesn't have a file input feature but there are a few work arounds out there using frames and hidden forms activated by javascript, the most well known is probably Yamzbrowser. They only work in IE unfortunately. But I really want to make an admin section in flash and this little problem is the only thing in my way so if anyone could answer my original question that would be great. By the way flash 8 now supports file upload and download apparently, but it will be a long time before enough browsers have flash 8 to make it worth while using.