我有一个问题需要找出相对路径 将图像上传到其他目录
目标目录
htdocs/dt3/tadi/adm/dim/dim_images/tadi_user_images/
源目录
htdocs/dt3/tadi/adm/cbt/uploadfile.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/
仅限相对路径。
答案 0 :(得分:6)
我相信你可以做到
$dirname = dirname(__FILE__)."/../dim/dim_images/tadi_user_images/"