1

我在找出将图像上传到其他目录的相对路径时遇到问题

目标目录

htdocs/dt3/tadi/adm/dim/dim_images/tadi_user_images/

源目录

htdocs/dt3/tadi/adm/cbt/uploadfile.php

上传文件.php

<html>
    <form method="post"enctype="multipart/form-data">
        <input type="file" name="fileimg1" ><input type="submit" name="upload">
    </form>
</html>


<?php
    $dirname = "/dt3/tadi/adm/dim/dim_images/tadi_user_images/";    

    $of = $_FILES['fileimg1']['name'];
    $ext = pathinfo($of, PATHINFO_EXTENSION);

    $changename3 = time() * 24 * 60;
    $image_name3 = "timage_" . $changename3 . "." . $ext;

    $final_pathdir = $dirname . $image_name3;
    $suc = move_uploaded_file($_FILES['fileimg1']['tmp_name'], $final_pathdir);

    if ($suc > 0) 
    {
        echo "Image uploaded successfully"; 
    } 
    else 
    {
        echo "Error : " . $_FILES['filimg1']['error'];
    }
?>  

我尝试了一些路径,我没有得到任何解决方案。
如何将图像上传到该路径?

htdocs/dt3/tadi/adm/dim/dim_images/tadi_user_images/

仅使用相对路径。

4

1 回答 1

6

我相信你能做到

$dirname = dirname(__FILE__)."/../dim/dim_images/tadi_user_images/"
于 2012-05-03T10:36:54.023 回答