A whole lot of people are very hesitant to make their hero appear weak, as the people we look up to personally are in our eyes virtually untouchable. So, with this in mind should a hero be allowed to fail, knowing it shatters that view of them? Yes, but temporarily.
You don't want the story to end with the bad guy winning, and then the credits roll. Your audience will feel bummed out, and feel as if they've been let down. Obviously if the story is ending with the knowledge there is another part to come after it can be okay as it would be the midway point, rather than the conclusion.
However, what you do want is for the hero to not be overly successful until the very end. To explain why I'm going to use a little bit of professional wrestling logic, and how fans tend to react to them.
When a guy is an underdog, and isn't really "the guy," he often has a rallied group of fans virtually begging for him to become champion. However, as soon as he finally becomes champion they virtually turn on him overnight. He isn't the underdog anymore. He doesn't represent them anymore.
Reason is, in my opinion, because anybody can support anybody when they're on the chase. Be it trying to win a world wrestling championship, trying to save the world, or even something as simple as getting a certain job. People want to rally behind the underdog.
However, just as with wrestling fans as soon as the hero saves the day people tend to question them. Likewise, if a guy gets a big promotion at work the same people who were telling him to go for it are likely to be bitter that it wasn't THEM who got the promotion. You can see this mentality with how people react to Spider-Man, referring to him as a criminal in spite of the fact he's clearly saving criminals.
So have the hero get little minor victories, but for every victory he needs to suffer devastating losses until the end. The reader has to believe he might not be able to win, because the victory will mean that much more when he pulls it off in the end. Hell, even Superman has to get his butt kicked on occasion.