当我尝试ftp.delete()从 ftplib 使用时,它会引发error_perm, resp:
>>> from ftplib import FTP
>>> ftp = FTP("192.168.0.22")
>>> ftp.login("user", "password")
'230 Login successful.'
>>> ftp.cwd("/Public/test/hello/will_i_be_deleted/")
'250 Directory successfully changed.'
>>> ftp.delete("/Public/test/hello/will_i_be_deleted/")
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ftplib.py", line 520, in delete
resp = self.sendcmd('DELE ' + filename)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ftplib.py", line 243, in sendcmd
return self.getresp()
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ftplib.py", line 218, in getresp
raise error_perm, resp
ftplib.error_perm: 550 Delete operation failed.
Run Code Online (Sandbox Code Playgroud)
该目录存在,并且“用户”有足够的权限删除该文件夹。
该站点实际上是一个支持ftp的NAS(WD MyBookWorld)。 …
我已经制作了一个正在等待文件的表格。提交后,文件将通过该ftp_put()功能上传到远程服务器。问题是它需要大约 2/3 分钟。
我尝试一一删除行以找出问题所在,但对它的调用ftp_put()花费了很多时间。文件只有20Ko。有没有办法在其他线程或其他线程中上传文件?
编辑:这是我的 php 代码。
$file = $_FILES['attachment']['tmp_name'];
$ext = pathinfo($_FILES['attachment']['name'], PATHINFO_EXTENSION);
$remote_file = '/cv_'.$_POST['first_name'].'_'.$_POST['last_name'].'_'.strval(time()).'.'.$ext;
$ftp_server = 'xxxxxxxxx';
$ftp_user_name = 'xxxxxx';
$ftp_user_pass = 'xxxxxx';
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
if (!ftp_put($conn_id, $remote_file, $file, FTP_ASCII)) /* This line is taking so long */
{
echo "There was a problem uploading the file $file\n";
}
ftp_close($conn_id);
Run Code Online (Sandbox Code Playgroud)
编辑 2:文件在几分钟后正确上传。该代码在本地主机上运行良好且快速,但是当它在生产服务器上时,它开始花费很长时间。
我对 opencart 完全陌生,并且没有技术经验。我已经在我知道的任何地方寻找答案。我已经在我的本地机器上安装了 Opencart2 并且想要使用 Exstension 安装程序。系统使用FTP,所以我使用Filezilla Server创建了一个本地FTP。没问题。然后我使用 FTP 凭据设置 Opencart 系统 FTP 设置。FTP 根设置为 localhost/mydomain 在运行扩展安装程序时,我收到以下错误:“语法错误:JSON.parse:JSON 数据的第 1 行第 1 列出现意外字符 OK <警告:ftp_chdir():CWD 失败。” /:/localhost/mydomain": 目录未找到。在C:\xampp\htdocs\mydomain\admin\controller\extension\installer.php第228行{"error":"
我尝试了 FTP 根文件夹的各种组合,即 Localhost, ,但似乎没有任何东西可以摆脱错误。如果有人能指导我,我将不胜感激。
谢谢
我想使用 ftp 帐户上传图像。我的代码是这样的。但是当我选择图像并提交时,它说“找不到文件'C:\Program Files (x86)\IIS Express\picture.jpg'。” 我知道我的图像在我的桌面上,我从那里选择。如果我手动复制我的图像这个 IIS 文件夹,它会上传,但这是不明智的。我必须在我想要的地方选择我的形象。但它正在 IIS Express 文件夹中查找。
[HttpPost, ValidateInput(false)]
public ActionResult Insert(Press model, HttpPostedFileBase uploadfile)
{
...........
...........
...........
...........
if (uploadfile.ContentLength > 0)
{
string fileName = Path.Combine(uploadfile.FileName);
var fileInf = new FileInfo(fileName);
var reqFtp =
(FtpWebRequest)
FtpWebRequest.Create(
new Uri("ftp://ftp.adres.com" + fileInf.Name));
reqFtp.Credentials = new NetworkCredential(username, password);
reqFtp.KeepAlive = false;
reqFtp.Method = WebRequestMethods.Ftp.UploadFile;
reqFtp.UseBinary = true;
reqFtp.ContentLength = uploadfile.ContentLength;
int bufferlength = 2048;
byte[] buff = new byte[bufferlength];
int contentLen;
FileStream fs = fileInf.OpenRead(); …Run Code Online (Sandbox Code Playgroud) 我设法使用 curl 连接到 FTP 服务器并列出目录的内容out:
$ curl -v --insecure --ftp-ssl --user xxx:yyy blabla:990/out/
> AUTH SSL
< 234 Proceed with negotiation.
...
> USER xxx
< 331 Please specify the password.
> PASS yyy
< 230 Login successful.
> PBSZ 0
< 200 PBSZ set to 0.
> PROT P
< 200 PROT now Private.
> PWD
< 257 "/"
> CWD out
< 250 Directory successfully changed.
> EPSV
< 229 Entering Extended Passive Mode (|||51042|).
* …Run Code Online (Sandbox Code Playgroud) 我需要读取本地文件并使用 FTP 复制到远程位置,我使用不同的名称(如 f1.txt、f2.txt...f1000.txt 等)将同一文件 file.txt 重复复制到远程位置数百次。现在,是否有必要始终为每个 FTP 副本打开、读取、关闭我的本地 file.txt,或者是否有办法将其存储到变量中并始终使用它,并避免文件打开、关闭功能。file.txt是6KB的小文件。下面是我正在使用的代码
for i in range(1,101):
fname = 'file'+ str(i) +'.txt'
fp = open('file.txt', 'rb')
ftp.storbinary('STOR ' + fname, fp)
fp.close()
Run Code Online (Sandbox Code Playgroud)
我尝试读取字符串变量并替换 fp 但 ftp.storbinary 需要第二个参数才能具有方法 read(),请建议是否有更好的方法来避免文件打开关闭,或者让我知道它是否根本没有性能改进。我在 Windows 7 上使用 python 2.7.10。
我使用带有 Java 8 的 Apache Commons Net (v3.5) 连接到远程 FTPS 站点(即在 Internet 上)。我可以在我的 Windows 10 机器上轻松连接 FileZilla 客户端,但我的 Java 程序无法完成相同的步骤。我在谷歌上搜索了高低,但找不到根本原因。以下是我已经确认的事情:
以下是代码,非常感谢您的任何想法:
import java.io.IOException;
import java.io.PrintWriter;
import org.apache.commons.net.PrintCommandListener;
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPFile;
import org.apache.commons.net.ftp.FTPReply;
import org.apache.commons.net.ftp.FTPSClient;
public class testProgram {
public static void main(String[] args) …Run Code Online (Sandbox Code Playgroud) 我是这种工作的新手,所以请帮助我。我将一个 xlsx 文件(一个 excel 文件)发送到服务器,我的代码中没有错误,或者在 ftp 服务器中,我在 xampp 中使用 filezilla。我在谷歌搜索并说它必须存储在一个 zip 文件中,但 zip 文件也已损坏。这是我的代码
FTPClient upload= new FTPClient();
File firstLocalFile = new File("C:/Users/user/desktop/sample.xlsx");
InputStream inputStream = new FileInputStream(firstLocalFile);
try {
upload.connect("localhost");
upload.login("user", "pass");
upload.enterLocalPassiveMode();
upload.storeFile("sample.zip", inputStream);
} finally {
try {
upload.logout();
upload.disconnect();
} catch (Exception e) {
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题有什么解决方案吗?
我有一个 Golang 应用程序,它应该连接到 FTP 服务器。
现在,Golang app 和 FTP Server 都已dockerized,但我不知道如何从 Golang app 连接到 FTP 服务器
这是我的 docker-compose.yml
version: '2'
services:
myappgo:
image: myappgo:exp
volumes:
- ./volume:/go
networks:
myappgo_network:
env_file:
- test.env
ftpd-server:
container_name: ftpd-server
image: stilliard/pure-ftpd:hardened
ports:
- "21:21"
- "30000-30009:30000-30000"
environment:
PUBLICHOST: "localhost"
FTP_USER_NAME: "test"
FTP_USER_PASS: "test"
FTP_USER_HOME: "/home/test"
restart: on-failure
networks:
myappgo_network:
networks:
myappgo_network:
Run Code Online (Sandbox Code Playgroud)
当我运行 docker compose 时,所有服务都已启动。
我可以通过以下方式获取 ftp 容器的 IP:
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ftpd-server
Run Code Online (Sandbox Code Playgroud)
然后,我在我的 golang 容器 lftp 中为 alpine 安装了一个 ftp 客户端: …
我有一个小型 Golang 程序,我正在尝试连接到在 docker 容器中运行的 FTP 服务器(https://registry.hub.docker.com/r/atmoz/sftp)。
我的机器是 M1 Pro MacBook。
使用以下命令启动容器:
docker run -p 22:22 -d atmoz/sftp foo:pass:::upload
Go 版本是 1.17.13。
程序的代码代码如下:
package main
import (
"log"
"time"
"github.com/jlaffaye/ftp"
)
func main() {
c, err := ftp.Dial("localhost:22", ftp.DialWithTimeout(5*time.Second))
if err != nil {
log.Fatal(err, " cannot connect")
}
err = c.Login("foo", "pass")
if err != nil {
log.Fatal(err, "cannot login")
}
// Do something with the FTP conn
if err := c.Quit(); err != nil {
log.Fatal(err) …Run Code Online (Sandbox Code Playgroud) ftp ×10
python ×3
docker ×2
ftplib ×2
java ×2
asp.net-mvc ×1
c# ×1
curl ×1
delete-file ×1
excel ×1
ftps ×1
go ×1
iis ×1
image ×1
networking ×1
opencart ×1
performance ×1
php ×1
ssl ×1
windows ×1