[BUG] displaying pics on Windows servers

Status
Not open for further replies.

cheesegrits

Support Gopher
There seems to be a little bugette in uploaded images on Windows based servers which prevents the image from being displayed when editing or viewing the form.

I think the problem is during upload, when the $destFile is processed in _uploadIndividualFile(), around line 2560 in fabrik.class.php. The code doesn't take account of the \ instead of / in the $destFile, so the switcheroonie of mosConfig_absolute_path for mosConfig_live_site doesn't work. So when the form gets rendered, the 'img src' ends up with a full URI followed by a whole Windows absolute path, which doesn't work too well.

The fix seems to be:

Code:
				mosChmod( $destFile );
                // $$$ hugh
                $dosFreeDestFile = str_replace('\','/',$destFile);
				$this->_form->_data[$elName] = str_replace( $mosConfig_absolute_path, $mosConfig_live_site, $dosFreeDestFile );

I'm also suspicious of this code a few lines up from the above, where it does the fileIncrement handling:

Code:
				//get the filename with out the path
				$newFileName = explode( "/", $destFile );
				$newFileName = end( $newFileName );

Looks like that will need tweaking to use the right path delimiter as well.

And of course, these fiixes don't help with any images uploaded prior to the above fix, so for full backward compat you would probably want to put some special case handling into drawFileUpload() as well. Basically do the same switcheroonie again, to catch any that are still set to C:\path\to\images instead of http://mysite.com/uri/to/images.

-- hugh
 
Hi Hugh,
I agree this is a window's specific bug and it relates to the / vs \ issue: Essentially the upload element type expects a relative system path from the root of the Joomla installation, hence images/mydir in linux and images\mydir in windows. While I think for consistency it should be the linux path, as it matches the URL formating, it can still get confusing if you are coming from the windows world or are expecting it to be a URL based path.

Andre
 
Apache 2.2 / Windows XP Pro, as per my sig.

There are several places in the code where you already do a str_replace('\\','/',$foo) to fix issues like this, I just stumbled on a couple more than need handling.

-- hugh
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top