开发者

Uploading files to external server using Perl

I have a Perl script on my computer which generates some text or images. I wish this data to be stored on an external ser开发者_如何学Cvice.

I have no experience with it, so I'd like to know how to do it, and what kind of features my server needs to have (I haven't picked one yet).

Thank you in advance.


Jason,

There are plenty of ways to upload your file to a remote server (or service). The simplest thing to do would be to upload a file using FTP. Most (if not all) web hostings provide FTP access. So, for example, you can upload your images using FTP to a specific folder where your service expects them. For that purposes you can use Net::FTP FTP Client class. Here is a simple example:

 use Net::FTP;

 $ftp = Net::FTP->new("some.host.name", Debug => 0);
 $ftp->login("anonymous",'-anonymous@');
 $ftp->cwd("/pub");
 $ftp->put("mylocalimage.png", "remoteimagename.png");
 $ftp->quit;  

If you have some more sophisticated software running on your server then you can use that server's API to upload an image. WordPress, for example, has XML-RPC protocol or publish via email function, and that will work on pretty-much every hosting. You can use WordPress's XML-RPC Perl module to upload an image, create a post in the blog etc. I wasn't able to find a good example using Perl, but here is C# one, it is pretty close.

Good luck!


You have to be more specific about what exactly you want to do, but a very generic answer would be to use Net::FTP.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜