下载存储在数据库中的文件 [英] Download the files stored in the database

查看:78
本文介绍了下载存储在数据库中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在数据库中存储了.doc,.txt,.zip,.jpg等文件。

我想给用户一个链接下载这些文件。

我希望以下载附件的方式下载它。

像用户应该有一个打开或保存文件的选项。

你能不能帮我解决这个问题。

Hi,
I ve stored .doc , .txt, .zip , .jpg, etc. files in the database.
I wanted to give the user a link to download those files.
I wanted it to be downloaded in a way as the attachments are downloaded.
Like the user should be given a option to open or save the file.
Can you plz help me how to go for it.

推荐答案




我在数据库中存储了.doc,.txt,.zip,.jpg等文件。

我想给用户一个下载这些文件的链接。

我希望以下载附件的方式下载它。

像用户应该有一个打开或保存文件的选项。

你能帮我解决这个问题吗?
Hi,
I ve stored .doc , .txt, .zip , .jpg, etc. files in the database.
I wanted to give the user a link to download those files.
I wanted it to be downloaded in a way as the attachments are downloaded.
Like the user should be given a option to open or save the file.
Can you plz help me how to go for it.



我不能给你整个代码,但可以告诉你正确的轨道。


使用 header ,然后从数据库中打印所需的数据。


例如。

for pdf, header(''Content-type:application / pdf'');

for jpg image header(''Content-type:image / jpeg'');

I can''t give you the whole code, but can show you the right track.

Use header in the starting of the PHP page and then print the required data from the database afterwards.

Eg.
for pdf, header(''Content-type: application/pdf'');
for jpg image header(''Content-type: image/jpeg'');


我已经阅读了那本手册,但我对它有疑问。

就像当用户注册时他存储了描述自己的图像或文字文档。因此,当用户查看另一个用户的个人资料时,应该给他一个选项来下载该特定用户上传的word文档。它从用户变为用户。它们在数据库中与用户名相关联。如何在标题中每次更改文件名,因为它对所有用户都是不同的。
I have gone through that manual but i had a doubt in it.
Like when a user registers he stores a image or a word document describing himself. So when a user views the profile of another user then he should be given an option to download the word document uploaded by that particular user. It changs from user to user. They are associated in the datbase with the name of the user. How can the filename be changed everytime in the header because it will be different for all the users.



我已经阅读了该手册但是我怀疑它。

就像当用户注册时他存储描述自己的图像或文字文件。因此,当用户查看另一个用户的个人资料时,应该给他一个选项来下载该特定用户上传的word文档。它从用户变为用户。它们在数据库中与用户名相关联。如何在标头中每次更改文件名,因为它对所有用户都是不同的。
I have gone through that manual but i had a doubt in it.
Like when a user registers he stores a image or a word document describing himself. So when a user views the profile of another user then he should be given an option to download the word document uploaded by that particular user. It changs from user to user. They are associated in the datbase with the name of the user. How can the filename be changed everytime in the header because it will be different for all the users.



为此,你需要让这样的逻辑运行,如果你打开页面 get_file.php?file = abc.doc ,它应该打开 abc.doc


看看帖子。这仅适用于图像类型,但它可能对您有所帮助。


问候,

Harpreet

For that you need to make a logic running behind like this, that if you open page get_file.php?file=abc.doc, it should open abc.doc.

Look at this post. This is only for image type, but it may help you.

Regards,
Harpreet


这篇关于下载存储在数据库中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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