ftp
ftp copied to clipboard
small fish ftp can't upload image !
i can't upload image into ftp
func Uper(w http.ResponseWriter , r _http.Request) {
ftp := new(ftp.FTP)
// debug default false
ftp.Debug = true
ftp.Connect(_ftp, 21)
// login
ftp.Login(*us, *ps)
if ftp.Code == 530 {
fmt.Println("error: login failure")
}
// pwd
ftp.Pwd()
fmt.Println("code:", ftp.Code, ", message:", ftp.Message)
// make dir
ftp.Request("TYPE I")
// stor file
bs := ioutil.ReadFile("./img_temp/myimage.png")
ftp.Stor("/images/myimage.png", bs)
ftp.Quit()
}
result on command line : <cmd> <code> 220 <message> FTP Server ready. <cmd> USER [myusername_secret] <code> 331 <message> Password required for [myuser_secret] <cmd> PASS [mypassword_secret] <code> 230 <message> User [myuser_secret] logged in. <cmd> PWD <code> 257 <message> "/" is the current directory code: 257 , message: "/" is the current directory <cmd> TYPE I <code> 200 <message> Type set to I <cmd> PASV <code> 227 <message> Entering Passive Mode (79,127,127,81,166,78).
i can't see error in this result ! all things ok ! upload success but image is bad ! image size before upload : 398724 byte And after upload : 0 byte !!! why? how solved this problem?