在Codeigniter中上传带有网址的图片

编程入门 行业动态 更新时间:2024-10-11 07:33:25
本文介绍了在Codeigniter中上传带有网址的图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

CodeIgniter上传库仅支持从PC上传图像文件。

CodeIgniter upload library only supports uploading image file from PC.

我正在尝试编写一个代码,使用户可以上传带有图像URL地址的图像。

I am trying to make a code that a user can upload image with image url address.

example/photo/jake2910.jpg

我只是将此图像地址发送到服务器并上传照片。

I simply send this image address to server and upload the photo.

做到这一点的方法? (相信我,我已经尝试了几天的不同代码。)

Is there a way to do that? (trust me I tried different codes already for few days.)

推荐答案

CI的上传库完全没有必要。您只需使用以下代码即可下载文件:

There is no need in CI's upload library at all. You can simply download the file with this code:

$url = 'example/photo/jake2910.jpg'; /* Extract the filename */ $filename = substr($url, strrpos($url, '/') + 1); /* Save file wherever you want */ file_put_contents('upload/'.$filename, file_get_contents($url));

但是请谨慎选择要保存的文件。请记住,即使图像也可能塞满易受攻击的代码。

But be very cautious about what files you are trying to save. Remember that even images can be stuffed with vulnerable code.

更多推荐

在Codeigniter中上传带有网址的图片

本文发布于:2023-10-10 09:42:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1478317.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:上传   网址   图片   Codeigniter

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!