Php 带有Uploadify的动态Filedestination

Php 带有Uploadify的动态Filedestination,php,javascript,jquery,file-upload,uploadify,Php,Javascript,Jquery,File Upload,Uploadify,我想把我的图片保存在不同的文件夹中,它属于我的mysql数据库条目 代码: 请帮帮忙我想它终于没有文件名了。试试这个,它可能对你有用: <?php if (!empty($_FILES)) { $tempFile = $_FILES['Filedata']['tmp_name']; // 1 @session_start(); $_SESSION['recipe_id'] = 5;

我想把我的图片保存在不同的文件夹中,它属于我的mysql数据库条目

代码:


请帮帮忙

我想它终于没有文件名了。试试这个,它可能对你有用:

<?php
    if (!empty($_FILES)) {
        $tempFile = $_FILES['Filedata']['tmp_name'];                          // 1
        @session_start();
        $_SESSION['recipe_id'] = 5;
        if (isset($_SESSION['recipe_id'])) {
            $path = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/'.$_SESSION['recipe_id'] .'/';
            if(!is_dir($path)) {
                mkdir($path);
            }
            $targetPath = $path;
            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++;

            $file_temp = $_FILES['Filedata']['tmp_name'];
            $file_name = $anzahl.prep_filename($_FILES['Filedata']['name']);
            $file_ext = get_extension($_FILES['Filedata']['name']);
            $real_name = $file_name;
            $newf_name = set_filename($path, $file_name, $file_ext);
            $file_size = round($_FILES['Filedata']['size']/1024, 2);
            $file_type = preg_replace("/^(.+?);.*$/", "\\1", $_FILES['Filedata']['type']);
            $file_type = strtolower($file_type);
            $targetFile =  str_replace('//','/',$targetPath) . $newf_name;
            move_uploaded_file($tempFile,$targetFile);
        }
        else {
            echo "Server Error";
        }
    }
    ?>

'script'    : '/uploadify/uploadify.php',
    'uploader'  : '/uploadify/uploadify.swf',
    'cancelImg' : '/uploadify/cancel.png',
    'folder'    : '/img/recipes',
    'auto'      : true
<?php
    if (!empty($_FILES)) {
        $tempFile = $_FILES['Filedata']['tmp_name'];                          // 1
        @session_start();
        $_SESSION['recipe_id'] = 5;
        if (isset($_SESSION['recipe_id'])) {
            $path = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/'.$_SESSION['recipe_id'] .'/';
            if(!is_dir($path)) {
                mkdir($path);
            }
            $targetPath = $path;
            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++;

            $file_temp = $_FILES['Filedata']['tmp_name'];
            $file_name = $anzahl.prep_filename($_FILES['Filedata']['name']);
            $file_ext = get_extension($_FILES['Filedata']['name']);
            $real_name = $file_name;
            $newf_name = set_filename($path, $file_name, $file_ext);
            $file_size = round($_FILES['Filedata']['size']/1024, 2);
            $file_type = preg_replace("/^(.+?);.*$/", "\\1", $_FILES['Filedata']['type']);
            $file_type = strtolower($file_type);
            $targetFile =  str_replace('//','/',$targetPath) . $newf_name;
            move_uploaded_file($tempFile,$targetFile);
        }
        else {
            echo "Server Error";
        }
    }
    ?>