简体   繁体   English

通过PHP页面上传FTP

[英]FTP upload through a PHP page

I have an administration page on a website, from which the admin AND THE ADMIN ONLY can manage users and upload files from local hard drive for these users to download. 我在网站上有一个管理页面,管理员和管理员只能从该页面管理用户并从本地硬盘驱动器上载文件,以供这些用户下载。 The admin uses this page to upload files for his customers or to store files he needs when he has no memory device available. 管理员使用此页面为客户上传文件,或者在他没有可用的存储设备时存储他需要的文件。 The files size may vary from a few Kb to a lot of hundreds megabytes. 文件大小可能从几Kb到数百MB不等。

The ideal solution: 理想的解决方案:

An HTML form through which the admin can choose a file and upload it, to download it back later. 一个HTML表单,管理员可以通过该表单选择文件并将其上传,以供日后下载。 This can be done in PHP. 这可以在PHP中完成。

The problems: 问题:

  1. I cannot set the "max_file_size" variable in php.ini because the hosting doesn't let me 我无法在php.ini中设置“ max_file_size”变量,因为托管无法让我
  2. I tried FTP upload (PHP function ftp_put()) but it requires me to upload the file with a POST anyway 我尝试了FTP上传(PHP函数ftp_put()),但无论如何我都需要我用POST上传文件
  3. Even though it's completely wrong, I used a input="text" instead of input="file" to write the whole file path and upload it, but I get the following error: 即使完全错误,我还是使用input =“ text”而不是input =“ file”来写入整个文件路径并上传,但是出现以下错误:

     Warning: ftp_put(insert_local_file_path_here)[function.ftp-put]: failed to open stream: No such file or directory in path_to_php_script.php on line 70 

The insane thing is... on Monday this was working, and now it's not. 疯狂的事情是……星期一工作了,现在却不行了。 No changes were done and the file is the same. 没有做任何更改,并且文件是相同的。

My only conclusion: With my little knowledge, all I could think of is a Java applet which does the required tasks that opens on the administration page. 我唯一的结论:据我所知,我所能想到的就是一个Java小程序,它执行在管理页面上打开的所需任务。 But if someone disables javascript/has no Java installed, the thing will not work, so it's not 100% bulletproof. 但是,如果有人禁用了javascript /未安装Java,则该操作将无法正常工作,因此并非100%防弹。

Have you got any ideas how to overcome such an issue? 您是否有解决此问题的想法?

If you need to upload big files you must use ftp protocol to make it. 如果需要上传大文件,则必须使用ftp协议来完成。 You can't upload big files if you don't have acces to php.ini. 如果您没有访问php.ini的权限,则不能上传大文件。 Sad but true 悲伤但真实

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM