【发布时间】:2014-06-07 09:26:59
【问题描述】:
我正在学习 Symfony2,我正在尝试将图像从手工表单上传到目标文件夹,但之前更改了它的名称。
我认为最简单的方法是:
move_uploaded_file(actual_file, destination_with_new_name)
但我收到以下错误消息:
ContextErrorException: Warning: move_uploaded_file(http://localhost/PublisherMyAdmin/web/app_dev.php/imagenesportadas/1.jpg): failed to open stream: HTTP wrapper does not support writeable connections in C:\xampp\htdocs\PublisherMyAdmin\src\ochodoscuatro\IntranetBundle\Controller\MaterialesController.php line 163
我的代码是:
$dir = $this->getRequest()->getUriForPath('/imagenesportadas/');
$nombre = $id.".".$extension;
if (move_uploaded_file($_FILES["archivo"]["tmp_name"], $dir.$nombre)) {
echo "Thank you for uploading your music!<br /><br />";
} else {
echo "Your file did not upload.<br /><br />";
}
谢谢!
【问题讨论】:
标签: php symfony image-uploading symfony-2.4