0
我想將我的照片保存在不同的文件夾中,它屬於我的mysql數據庫條目。Uploadify的動態文件目標
代碼:
<?php
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name']; // 1
@session_start();
$_SESSION['recipe_id'] = 5;
if (isset($_SESSION['recipe_id']))
{
$location = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/'.$_SESSION['recipe_id'] .'/';
if(!is_dir($location))
{
mkdir($location);
}
$targetPath = $location;
include 'db_connect.php';
$sql = "SELECT recipes_id FROM IMAGE WHERE recipes_id="+$_SESSION['recipe_id'];
$result = mysql_query($sql,$db) or exit("QUERY FAILED!");
$anzahl = mysql_num_fields($result);
$anzahl++;
$targetFile = str_replace('//','/',$targetPath) . $anzahl.$_FILES['Filedata']['tmp_name'];
move_uploaded_file($tempFile,$targetFile);
}
else
{
echo "Server Error";
}
}
?>
該文件夾將被創建,但沒有畫面是在正確的文件夾。
Uploadify設置:
'script' : '/uploadify/uploadify.php',
'uploader' : '/uploadify/uploadify.swf',
'cancelImg' : '/uploadify/cancel.png',
'folder' : '/img/recipes',
'auto' : true
請幫