如何导出图像与CSV文件在PHP中? [英] How can i export images with CSV file in php?

查看:519
本文介绍了如何导出图像与CSV文件在PHP中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在导出CSV文件,但我想导出图像也应该怎么办?

I am exporting CSV file correctly but i want to export images also what should i do?

感谢提前
尊敬的
kiran

Thanks in advance Regards kiran

推荐答案

语句



Statement

You can't really have images in a CSV document in any logical way.

如果是使用网址托管的图片,

If it is an image hosted somewhere with a URL then you could include the URL as a value in the CSV.

否则,您可以包含整个图片作为base64编码字符串:

Otherwise you could include the whole image as a base64 encoded string:

 $fh = fopen('/my/tmp/file.csv');
 $values['name'] = 'Kiran';
 $values['image'] = base64_encode(file_get_contents('/my/file/path.jpg'));
 fputcsv($fh, $fields);

这篇关于如何导出图像与CSV文件在PHP中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆