Upload a file - type io.Reader is not an expression

I have some problem to upload an existing file to a ftp using jlaffaye/ftp. There is no “upload” command. The closest I have found is StorFrom()

But the syntax is a hidden secret for me. I cannot find any example how to use this.

package main

import (

func send2ftp(filename string) {
	c, err := ftp.Dial("ftp.test.com:21", ftp.DialWithTimeout(5*time.Second))
	if err != nil {

	err = c.Login("test", "test")
	if err != nil {

	if _, err := os.Stat(filename); err != nil {
		if os.IsNotExist(err) {
			fmt.Println("does not exist")
	} else {

	err = c.StorFrom(filename, io.Reader, 0)
	if err != nil {


This attempt to find a syntax gives this error:

type io.Reader is not an expression

The question is simple: How do I upload an existing file to ftp? Or how do I create a file at ftp using a []string value.

(*ServerConn).StorFrom expects to be passed something that implements io.Reader. If you want to upload a file from your computer, you can use os.Open to open the file and then pass the file to StorFrom. Don’t forget to close the file when you’re done!


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.