Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: ftp upload fails  (Read 2515 times)

0 Members and 1 Guest are viewing this topic.

Comme le vent

  • Newbie
  • *
  • Posts: 3
    • View Profile
ftp upload fails
« on: April 04, 2011, 11:02:18 am »
Hey guys, hi laurent
i have a small problem: I'm trying to upload an html to a parallels confixx server, but it doesn't work. It is a file that i download, change, and then want to upload again to overwrite it. The download works, but when uploading response.GetStatus() gives 1003, which according to the documentation is invalid file. But i don't understand what it means, the file is not currupt and the program should be able to find it as it is in the directory of the exe. I tried "C:\\file.html" and copied it there but that doesn't help either.
What's the issue?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
ftp upload fails
« Reply #1 on: April 04, 2011, 12:16:32 pm »
This is definitely a path problem, SFML returns 1003 on upload when the file couldn't be opened.

Try this to make suree that it has nothing to do with SFML or FTP:
Code: [Select]
#include <fstream>
#include <iostream>

int main()
{
    std::ifstream file("whatever/file.html");
    if (!file)
        std::cout << "error" << std::endl;

    return 0;
}
Laurent Gomila - SFML developer

Comme le vent

  • Newbie
  • *
  • Posts: 3
    • View Profile
ftp upload fails
« Reply #2 on: April 04, 2011, 01:03:32 pm »
i already do this.

Code: [Select]

std::ifstream in("plan.html");
if(!in.is_open()) { std::cerr << "Error: cannot open ifstream." << std::endl; return; }


The ifstream is ok and the file is copied into a std::string which is parsed & edited and then written to file. The resulting html is displayed correctly offline in firefox and online after manual upload with filezilla. Even if i only download the file without opening and editing it, the upload fails. The ifstream rading the file from c:\\plan.html works as well.

edit: os is vista ultimate, compiler vc++2005 if it matters.
upload is
Code: [Select]
resp = server.Upload("", "plan.html");
if(!resp.IsOk()) { std::cerr << "\nError " << resp.GetStatus() << ". Failed to upload to server.\n"; }

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
ftp upload fails
« Reply #3 on: April 04, 2011, 01:10:46 pm »
Well, here are the first lines of the Ftp::Upload function:

Code: [Select]
Ftp::Response Ftp::Upload(const std::string& LocalFile, const std::string& DestPath, TransferMode Mode)
{
    // Get the contents of the file to send
    std::ifstream File(LocalFile.c_str(), std::ios_base::binary);
    if (!File)
        return Response(Response::InvalidFile);

And this is the only place where InvalidFile can be returned.

Are you sure that you didn't invert the arguments (must be local file first, then distant path)?
Laurent Gomila - SFML developer

Comme le vent

  • Newbie
  • *
  • Posts: 3
    • View Profile
ftp upload fails
« Reply #4 on: April 04, 2011, 01:14:30 pm »
Quote
Are you sure that you didn't invert the arguments (must be local file first, then distant path)?

jesus christ. I successfully embarassed myself. :roll:

Anyway thanks a lot.

 

anything