Hi, does anyone know the script for a php script backend to a flash app that would upload files? basically i want to upload the file into a mysql database and then using mysql_insert_id(); send back the id. I was thinkin of using sessions to store the id and then using loadvars in flash call another php script that would send the id stored in the session. I tried something but it doesn’t seem to update the session variable but does insert into the databse.
<?
session_start();
require_once(“database_connect.php”);
if ($_FILES[‘Filedata’][‘name’]){
$fileName = $_FILES[‘Filedata’][‘name’];
$tmpName = $_FILES[‘Filedata’][‘tmp_name’];
$fileSize = $_FILES[‘Filedata’][‘size’];
$fp = fopen($tmpName, 'r');
$content = fread($fp, $fileSize);
$content = addslashes($content);
fclose($fp);
$query = "INSERT INTO files (file_name, size, file) ".
"VALUES ('$fileName', '$fileSize','$content')";
mysql_query($query) or die('Error, query failed');
$_SESSION['fileId'] = "check";
}
?>