Skip to content

[3.0] _normalizePath and _replaceTokens break paths on WAMP #68

@tomws

Description

@tomws

I'm having trouble with _normalizePath and _replaceTokens and image paths when developing on WAMP.

Uploading a file causes the file path to be stored with an absolute Windows path. For example, using a 'dir' setting of 'uploads/{ModelName}' and uploading the file 'myfile.jpg' saves the 'dir' data as C:\wamp\www\my_app_name\app\webroot\uploads\my_model_name\myfile.jpg. The file is saved to the correct location, but Apache cannot display an image from that absolute path. If I comment out the call to _normalizePath on line 95 (inside the setup function, commit 14d1467... I think), I'm able to solve part of the problem. The path saves as a relative "uploads\my_model_name" and I can build a path from which Apache can display the images.

The other part of the problem deals with _replaceTokens (line 555 of the same commit) forcefully overwriting manually entered directory separators. If it would only replace the tokens, my dir path above with "/" would be fine, but the function replaces both forward and back slashed with the system's DS - in this case, a Windows backslash. That would seem to be beyond desired capability, imho. To fix this problem, I had to comment out the last two parameters of the search and replace arrays in _replaceToken's str_replace function, as below:
return str_replace(
array('{ModelName}', '{fieldName}', '{DS}'),//, '/', ''),
array(Inflector::underscore($model->name), $fieldName, DS),//, DS, DS),
$string
);

I'm unsure if this is an inherent problem with developing on a Windows system, or if it's a problem with meio_upload's path handling. Can someone advise how the situation should be handled?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions