WikiDocs icon indicating copy to clipboard operation
WikiDocs copied to clipboard

Attachments path error

Open lbarriocanal opened this issue 1 year ago • 12 comments

Describe your issue

Attachments in pages show a wrong path for open or download. Subdirectory appears twice in url.

Device and settings

WikiDocs-1.0.14

Steps to reproduce

  1. Upload attachment to a page in wikidocs
  2. Save
  3. Attachment is stored in domain.com/wikidocs/datasets/documents/
  4. Link to attachment shows domain.com/wikidocs/wikidocs/datasets/documents/
  5. I get Error 404 when clicking

Screenshots (optional)

No response

Extra fields

  • [ ] I'd like to work on this issue

lbarriocanal avatar Feb 06 '24 22:02 lbarriocanal

In addition, I can´t delete attachments

lbarriocanal avatar Feb 07 '24 07:02 lbarriocanal

i think is a problem of the configuration path.. can you paste your config.inc.php ?

Zavy86 avatar Feb 07 '24 07:02 Zavy86

config.inc.php

<?php define('DEBUGGABLE',false); define('PATH',"/wikidocs/"); define('LANG',"es"); define('TIMEZONE',"Europe/Madrid"); define('TITLE',"Wiki|Docs"); define('SUBTITLE',"flat-file markdown wiki engine"); define('OWNER',"admin"); define('NOTICE',"admin"); define('PRIVACY',null);

Site is hosted in subdomain

lbarriocanal avatar Feb 07 '24 08:02 lbarriocanal

your url is https://domain.com/wikidocs ? or https://subdomain.domain.com/ ?

Zavy86 avatar Feb 07 '24 08:02 Zavy86

https://subdomain.domain.com/wikidocs/

lbarriocanal avatar Feb 07 '24 08:02 lbarriocanal

ok i will try to fix the bug in this way..

but if you can is better to setup the wiki in https://subdomain.domain.com/ as a workaraound

Zavy86 avatar Feb 07 '24 08:02 Zavy86

Hi,

Now when I try to upload pdf file it add path "wiki" 2 times because my wikidocs it's stored on sub-folder https://domain.pt/wiki/

Steps to reproduce

  1. Edit page
  2. Select Upload attachment
  3. Make "save" click outside the pop-pup because click on name file won't work
  4. Attachment is stored in https://domain.pt/wiki/wiki/datasets/documents/homepage/temp/t3/evelyn.pdf
  5. When click on page link to open attachment evelyn.pdf shows https://domain.pt/wiki/wiki/datasets/documents/homepage/temp/t3/evelyn.pdf and I get Error 404
  6. If i remove one /wiki to https://domain.pt/wiki/datasets/documents/homepage/temp/t3/evelyn.pdf, work's fine.
  7. When I get Error 404 I need to click on page head name to return to some "work" zone because all tree url name goes to Error 404

ffiesta avatar Feb 26 '24 16:02 ffiesta

can you paste also your actual configuration file?

Zavy86 avatar Feb 28 '24 19:02 Zavy86

My config.inc.php file

<?php
define('DEBUGGABLE',false);
define('PATH',"/wiki/");
define('LANG',"en");
define('TIMEZONE',"Europe/Lisbon");
define('TITLE',"P|Docs");
define('SUBTITLE',"markdown wiki engine");
define('OWNER',"Paulo");
define('NOTICE',"Copyright © All rights reserved");
define('PRIVACY',null);
define('EDITCODE',"64b2ce1c532c802e7a96");
define('VIEWCODE',"11d92675885d0");
define('COLOR',"#4CAF50");
define('DARK',false);
define('GTAG',null);

My instalation is on https://domain.pt/wiki/

ffiesta avatar Feb 28 '24 19:02 ffiesta

In my wikidocs tests when i made [link](/) this goes to domain.pt instead domain.pt/wiki.

I don't know if this is related.

ffiesta avatar Feb 28 '24 19:02 ffiesta

Hi,

I try to solve this problem, ... and I don't know if the best way. I will try to explain.

I will use this 2 domains:

  1. wikidocs on root with domain http://www1.test/
    • htaccess:RewriteBase /
    • config.inc.php: define('PATH',"/");
  2. wikidocs on sub-folder in folder with domain http://web-xpto.test/6Ji7bClRFYcnMWE9.Jj6jCrIvLB6KPK26/wikidocs21/
    • htaccess:RewriteBase /6Ji7bClRFYcnMWE9.Jj6jCrIvLB6KPK26/wikidocs21/
    • config.inc.php: define('PATH',"/6Ji7bClRFYcnMWE9.Jj6jCrIvLB6KPK26/wikidocs21/");

After some review I identify LINE 209 on classes/Document.class.php $attachment->url=substr(URL,0,-1).$this->PATH."/".$element_fe; that cause this issue create attachments url http://web-xpto.test/6Ji7bClRFYcnMWE9.Jj6jCrIvLB6KPK26/wikidocs21/6Ji7bClRFYcnMWE9.Jj6jCrIvLB6KPK26/wikidocs21/datasets/documents/ficheiros/pdf.pdf

After some test i identify that substr(URL,0,-1) has this url /6Ji7bClRFYcnMWE9.Jj6jCrIvLB6KPK26/wikidocs21/ and PATH has /6Ji7bClRFYcnMWE9.Jj6jCrIvLB6KPK26/wikidocs21/, if we only add substr(URL,0,-1) or PATH the url stays incomplete http://web-xpto.test/6Ji7bClRFYcnMWE9.Jj6jCrIvLB6KPK26/wikidocs21/6Ji7bClRFYcnMWE9.Jj6jCrIvLB6KPK26/wikidocs21/pdf.pdf won't attach the ID datasets/documents/ like LINE 28 or 29 function says.

To solve the problem I change LINE 209 on classes/Document.class.php from $attachment->url=substr(URL,0,-1).$this->PATH."/".$element_fe; to $attachment->url=PATH."datasets/documents/".$this->ID."/".$element_fe; and it work on 2 cases, wikidocs on root and wikidocs on folder or subfolder.

Please review.

ffiesta avatar May 31 '24 11:05 ffiesta

Hi @Zavy86,

Please check my solution https://github.com/Zavy86/WikiDocs/issues/104#issuecomment-2141831767 to wikidocs on subfolder and include on new release.

Thanks

ffiesta avatar Jun 08 '24 12:06 ffiesta