下载使用与服务器上的名称不同的名称上载的文件 [英] Downloading Uploaded files under a different name than the one on the server

查看:77
本文介绍了下载使用与服务器上的名称不同的名称上载的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我对php很新。而且我必须很快提交一个项目(明天晚上)。所以请帮忙。

问题是这个。我已经创建了一个文件上传机制,其中上传的文件存储在不同的id下,用于安全性,如0001.pdf,0002.jpg等。原始名称存储在mysql数据库中。现在我有一个文件下载页面。链接是文件的原始名称,如user1.pdf,user2.pdf ...当点击链接时,出现的文件名称为0001,0002等,即服务器上的文件。

我希望它以上传的原始名称下的user1.pdf,user2.pdf等打开。怎么做?

Hi,
I am very new to php. And I have got to submit a project very soon (By tomorrow evening). So please help.
The problem is this. I have created a file upload mechanism where the uploaded files are stored under a different id for security something like 0001.pdf, 0002.jpg etc.. The original names are stored in a mysql database. Now I have a file download page. The links are the original names of the files like user1.pdf, user2.pdf... When the link is clicked the file that comes up has the name 0001,0002 etc ie the one on server.
I want it to open as user1.pdf, user2.pdf etc that is under the original name in which they were uploaded.. How to do this?

推荐答案

Heya,suryadithya。欢迎来到TSDN!


您需要创建一个直接输出图像的PHP脚本,然后将PHP脚本作为图像标记的src。


例如,请查看这篇文章。有些阅读有点沉重,但你应该在页面的中间找到你正在寻找的概念和语法。
Heya, suryadithya. Welcome to TSDN!

You''d need to create a PHP script that outputs the images directly and then make the PHP script the src of the image tag.

For an example, check out this article. Some of the reading is a bit heavy, but you should find the concepts and syntax that you''re looking for about halfway down the page.



Heya,suryadithya。欢迎来到TSDN!


您需要创建一个直接输出图像的PHP脚本,然后将PHP脚本作为图像标记的src。


例如,请查看
这篇文章。有些阅读有点沉重,但你应该找到你在页面中间寻找的概念和语法。
Heya, suryadithya. Welcome to TSDN!

You''d need to create a PHP script that outputs the images directly and then make the PHP script the src of the image tag.

For an example, check out this article. Some of the reading is a bit heavy, but you should find the concepts and syntax that you''re looking for about halfway down the page.



感谢您的回复pbmods。但这篇文章对我来说非常沉重。而且我不认为这解决了我的问题。我已经允许上传几种文件类型而不仅仅是图像。它们不会以原始名称存储在服务器上的任何位置。名称的唯一来源是mysql db。

我想要的是当用户点击另存为时该文件应保存在db下的原始名称下。不是服务器上的那个。

Thank you for that reply pbmods. But the article was very heavy for me. And I don''t think that solved my problem. I have allowed upload of several file types not just images. They are not stored under their original names anywhere on the server. The only source of the names is the mysql db.
What I want is when the user clicks on "save as" the file should be saved under it''s original name on the db. Not the one on the server.


Heya,Suryadithya。


Hm。因此,您需要能够使用别名加载任何文件。

Heya, Suryadithya.

Hm. So you need to be able to load any file by using an alias.

展开 | 选择 | Wrap < span class =codeDivider> | 行号


这篇关于下载使用与服务器上的名称不同的名称上载的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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