duansengcha9114 2016-09-28 21:47
浏览 36
已采纳

用户图片上传

I am currently developing a web app. In a few places I allow users to upload images for various reasons. Now that the site is live (hosted on GoDaddy) I can't seem to figure out the best place to put the images that are being uploaded. I do have an external server which runs my database, but it is not set up for FTP so I can't easily use my PHP backend to upload them and retrieve them. To me it does not seem like a good idea to store them directly on GoDaddy either.

Should I create an FTP server to do this? or are there better options.

  • 写回答

2条回答 默认 最新

  • drxdn40242 2016-09-28 21:58
    关注

    If you want to store the images on a remote system, then you indeed do need some way to transfer them. Specifically that means you need to setup and operate a server and you need to use a client to trigger the actual transfers. This limits your possible choices to those client implementations available on your wen hosting platform.

    FTP is such a protocol, to use it you would obviously need a FTP server. However the issue with FTP is that it is a dinosaur from an area long gone. It is a left over from the 1970th. Totally outdated. It was designed for a network topology that had completely different challenges than todays internet. And indeed it does create a lot of issues. First, it does not encrypt the transferred data. That is a huge privacy issue, obviously. There are indeed versions these days that offer encryption. However that protocol variant, called FTPS, only encrypts the communication channel, whilst all other channels, all those used to transfer the actual files, stay not encrypted. The second big issue with that protocol is that it requires quite some effort for the firewall setup. It opens a separate network connection for each transfer which is inefficient. Separate ports are expected to be open towards the internet. A nightmare for firewall administrators. And it might even be that the protocol cannot be used in some situations, for example it is nearly impossible to use FTP in combination with port forwarding scenarios. That is why FTP is not really a good choice for what you plan in my eyes. Though indeed it still is in wide spread use these days.

    An immediate alternative is the "modern drop in replacement", the SFTP protocol. Though called similar and indeed serving exactly the same purpose, it is a completely separate protocol from a technical point of view. It operates based on the secure shell protocol (SSH) for which servers are also wide spread and proven. It offers strong encryption, offers means for all activities required for the task at hand and is much easier to configure with look on the network setup. All traffic, so control and payload traffic is sent though a single network connection. Most implementations are developed as Open Source project with all the benefits in security and fast reaction on potential issues that come up. Another plus: it allows authentication based on asymmetric key pairs instead of passwords which further raises the security. This protocol is my personal choice. Also because you need to operate an ssh server anyway to manage your systems. This keeps the footprint small ;-)

    There are further alternatives like WEBDAVS for example. But they are less well known, less easy to setup. Which is why I would recommend against such experiments, except if there are very specific reasons.

    A last option are network shares. That allows to treat file transfer between systems like local file operations which obviously is a big plus. Such connections can be encrypted, but are not really designed for long distance communication. So this depends a bit on your specific situation. Typical choices here would be NFS or SMB/CIFS (Samba). Probably also some newer "distributed file systems" might be usable. But I cannot say much about those due to lack of personal experience ;-) The biggest issue I see with this option is that it requires privileged access to the client system (so your web hosting platform), since you have to mount the share into the local file system, be it on system or on user level. This typically is not possible in cheap web hosting scenarios.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?