浏览目录文件并将 url 传递给 PHP,或上传并传递 URL
我已经搜索了整整 3 个小时,我对如何做一些我认为非常简单的事情感到困惑(著名的遗言......)
基本上,我正在构建一个允许用户上传 pdf 的网站文件。该文件的 URL 以及名称和一些其他详细信息存储在数据库中。我正在尝试解决如何:
- 提供一个“上传”框/按钮/区域,用户可以选择文件,上传它,然后将文件上传位置的 URL 存储在数据库中。
或者
- 使用单独的上传脚本,并让用户上传文件。然后,(我不介意在一个可能单独的页面上)提供一个文件浏览器,它允许用户浏览目录并选择一个文件,并将该文件的 url 传递到 PHP 表单。
我不介意以哪种方式完成,只要上传文件并将 URL 添加到数据库的预期结果即可。
或者我超出了 PHP 的范围?我最好的选择是通过裸露的 php 上传器上传文件,然后手动将上传的文件的 url 输入到 php 表单的文本框中?
非常感谢任何帮助!
I've been searching for a good 3 hours, and I'm stumped on how to do something I think is pretty simple (famous last words...)
Basically, I'm building a site that allows the user to upload a pdf file. The URL of this file is stored in a database, along with the name and a few other details. I am trying to work out how to either:
-Provide an "upload" box/button/area that a user can select a file, upload it, and then have the URL of where the file was uploaded stored in a database.
OR
-Use a separate upload script, and have the user upload the file. Then, (on a possibly separate page, I don't mind) provide a file browser, which would allow the user to browse a directory, and select a file, with the url of that file passed through to the PHP form.
I don't mind which way it is done, as long as the desired outcome of having a file uploaded and the url added to a database.
Or am I out of the reach of PHP? Is my best bet uploading files via a bare php uploader, then manually entering the url of the file uploaded into a textbox on a php form?
Any help is much appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 PHP 中的“multipart/form-data”
"multipart/form-data"