在文件上传路径中连接php变量

时间:2016-05-19 07:19:26

标签: php concatenation

$i = 3292;

move_uploaded_file($_FILES['doc_path']['tmp_name'], '../../../../uploads/documents/'.$i.'/'.$photograph);

move_uploaded_file($_FILES['doc_path']['tmp_name'], '../../../../uploads/documents/3292/'.$photograph);

上面的代码有什么问题。连接也是正确的但是当我使用$ i static时它工作正常。请帮助

1 个答案:

答案 0 :(得分:0)

将路径存储在一个变量中并使用它。

$i = 3292;
$path = '../../../../uploads/documents/'.$i.'/'.$photograph;

move_uploaded_file($_FILES['doc_path']['tmp_name'], $path);

move_uploaded_file($_FILES['doc_path']['tmp_name'], '../../../../uploads/documents/3292/'.$photograph);