将文件从临时文件夹移动到php中的子文件夹

时间:2015-04-06 21:16:01

标签: php

我正在尝试将文件从临时文件夹移动到子文件夹,但它没有移动它。我看过其他帖子,但我尝试的一切都没有改变帮助。 - 更新版本

<?php 

if (isset($_POST['submit'])){
    include("connect.php");
}

//Get current working directory
$curdir = getcwd();
$file = "image";

$username  = $_POST['user'];
$imageName = mysql_real_escape_string($_FILES["image"]["name"]);
$imageData = mysql_real_escape_string(file_get_contents($_FILES["image"]["tmp_name"]));
$imageType = mysql_real_escape_string($_FILES["image"]["type"]);
$tmp_name  = mysql_real_escape_string($_FILES["image"]["tmp_name"]);

//check if file is an image
if(substr($imageType,0,5) == "image"){
    //check if directory exists.
    if (is_dir($file)){
        //if directory does exists
        if(move_uploaded_file($tmp_name, '$file/$imageName')){
            //
            echo "$username this is an $imageType";
        }else{
            echo "There is a problem with $tmp_name";
        }

    }else{
        //if directory doesnt exists
        mkdir($file , 0777);
        echo "$file created";
    }
}else{
    //if file is not an image
    echo "This is not an image";
}

&GT;

0 个答案:

没有答案