Codeigniter - 无法打开流:HTTP 包装器不支持可写连接
Codeigniter - failed to open stream: HTTP wrapper does not support writeable connections
我在 codeigniter 中上传图片时遇到问题
这是我的观点:
<form method="post" action="<? echo site_url('do_upload'); ?>" id="createForm" enctype="multipart/form-data" >
<div style="display:none">
<input type="hidden" name="<?php echo $this->security->get_csrf_token_name(); ?>" value="<?php echo $this->security->get_csrf_hash();?>" />
</div>
<div class="form-group">
<label for="exampleInputFile">Picture</label>
<input type="file" name="picture" id="exampleInputFile">
<p class="help-block">Choose file to upload.</p>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Save changes</button>
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</form>
我的控制器:
public function do_upload()
{
if(isset($_FILES['picture']))
{
$dossier = base_url().'assets/image/product/';
$fichier = basename($_FILES['picture']['name']);
if(move_uploaded_file($_FILES['picture']['tmp_name'], $dossier . $fichier)) //Si la fonction renvoie TRUE, c'est que ça a fonctionné...
{
echo 'Upload effectué avec succès !';
}
else //Sinon (la fonction renvoie FALSE).
{
echo 'Echec de l\'upload !';
}
}
}
我一直都遇到这个问题:
Screen shot error
文件上传功能不支持基于 HTTP 和 https 的文件路径。另外,如果您使用基于 linux 的 os,例如 ubuntu 或 mac 来授予文件夹权限,则为 ex 所有文件夹的 777。 assets , image 和 product 这三个文件夹需要读写权限 777
public function do_upload()
{
if(isset($_FILES['picture']))
{
$dossier ='./assets/image/product/'; //based folder path if is inside public so u can use $dossier = './public/assets/image/product/';
$fichier = basename($_FILES['picture']['name']);
if(move_uploaded_file($_FILES['picture']['tmp_name'], $dossier . $fichier)) //Si la fonction renvoie TRUE, c'est que ça a fonctionné...
{
echo 'Upload effectué avec succès !';
}
else //Sinon (la fonction renvoie FALSE).
{
echo 'Echec de l\'upload !';
}
}
}
我在 codeigniter 中上传图片时遇到问题 这是我的观点:
<form method="post" action="<? echo site_url('do_upload'); ?>" id="createForm" enctype="multipart/form-data" >
<div style="display:none">
<input type="hidden" name="<?php echo $this->security->get_csrf_token_name(); ?>" value="<?php echo $this->security->get_csrf_hash();?>" />
</div>
<div class="form-group">
<label for="exampleInputFile">Picture</label>
<input type="file" name="picture" id="exampleInputFile">
<p class="help-block">Choose file to upload.</p>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Save changes</button>
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</form>
我的控制器:
public function do_upload()
{
if(isset($_FILES['picture']))
{
$dossier = base_url().'assets/image/product/';
$fichier = basename($_FILES['picture']['name']);
if(move_uploaded_file($_FILES['picture']['tmp_name'], $dossier . $fichier)) //Si la fonction renvoie TRUE, c'est que ça a fonctionné...
{
echo 'Upload effectué avec succès !';
}
else //Sinon (la fonction renvoie FALSE).
{
echo 'Echec de l\'upload !';
}
}
}
我一直都遇到这个问题:
Screen shot error
文件上传功能不支持基于 HTTP 和 https 的文件路径。另外,如果您使用基于 linux 的 os,例如 ubuntu 或 mac 来授予文件夹权限,则为 ex 所有文件夹的 777。 assets , image 和 product 这三个文件夹需要读写权限 777
public function do_upload()
{
if(isset($_FILES['picture']))
{
$dossier ='./assets/image/product/'; //based folder path if is inside public so u can use $dossier = './public/assets/image/product/';
$fichier = basename($_FILES['picture']['name']);
if(move_uploaded_file($_FILES['picture']['tmp_name'], $dossier . $fichier)) //Si la fonction renvoie TRUE, c'est que ça a fonctionné...
{
echo 'Upload effectué avec succès !';
}
else //Sinon (la fonction renvoie FALSE).
{
echo 'Echec de l\'upload !';
}
}
}