Recently a customer of mine who uses Joomla to drive several sites came to me to see if I could help him with a problem. When he tried to install a new Joomla add-on using Joomla’s FTP installation option it would always fail with the error message “JFTP::store: Bad Response”
A google search turned up lots of other folks with the same problem. The only “fix” offered was to either switch hosting providers, or to disable the FTP option and use the direct install option.
Well, the first suggestion is just plain silly. It has nothing to do with your hosting provider. It’s not a safemode issue. Frankly it’s an all too common response from programmers who are too lazy to track down their own bugs.
The second “fix” is almost as useless. Yes, the non-FTP option will allow the install to work on many servers, but not all of them. And even if you can use that option, it still has a problem: you see, on most shared hosting servers PHP scripts run as the same user as the web server software (typically “nobody” or “www” or “apache” etc.) So when it installs your add-on directly, the files are owned by that user. But files uploaded via FTP are usually owned by the same user as the rest of the files in your account (you!) So what happens later if you want to download/edit/delete those files via FTP or the shell? Often you can’t. You don’t own them.
In any case, even though I’m no Joomla expert I thought I’d give it a shot. I found the problem fairly quickly, and it’s a programming oversight (a bug, to be blunt about it). The fix involves adding three short lines of code to one file. That’s it.
Background: When you upload a file to a PHP script, it is stored in a temporary file space. On any properly configured shared web host, this temporary file space is protected. Your PHP scripts cannot directly access arbitrary files in this area (you wouldn’t want other users on the same host to intercept your uploads would you?)
A well written PHP script will use the handy PHP function named move_uploaded_file() to first move the newly uploaded file into the script’s local file space before trying to do anything with it. If you try to access the uploaded file via any other means while it’s still in the temporary file space, it will fail.
And this is the problem with Joomla’s FTP uploading option. It tries to FTP the file directly from the temporary upload area to the final destination. It hides the real error behind the rather cryptic “FTP::store: Bad response” message.
Here’s the fix. Edit this file in the Joomla installation:
libraries/joomla/filesystem/file.php
Around line 327 (at the time I write this) you should see these two lines:
if (($FTPOptions['enabled'] == 1) { // Connect the FTP client
Insert these three lines of code between those two lines:
$tmp = $baseDir . '/' . getmypid(); move_uploaded_file($src, $tmp); $src = $tmp;
Basically we create a new temporary file name inside the Joomla file space, call move_uploaded_file() to move the uploaded file to this location, point $src at the new file location, and carry on.

Ajax: The Definitive Guide
Friday, 21. November 2008
Hey Mark,
Thanks for finding and fixing that!
It’s working like a charm on my Joomla sites. It’s so nice to have everything installing under my ftp accounts instead of the dreaded “nobody”!
- Tim