Joomla 5 Notice

We are pleased to announce that as of January 29, 2024, all of our Joomla extensions are compatible with Joomla 5.

For all who are still updateing from Joomla 3 to Joomla 4: Joomla 4 Migration instructions are available here:

There is now a separate Documentation for Visforms for Joomla 4 and for Visforms for Joomla 5!

Forum

Visforms Subscription user can ask questions in our forum. Please log in with the relevant user first.
Everybody can access the forum for reading.

Please only ask 1 question per topic.

Wrong upload folder link

More
8 years 8 months ago #1956 by poussemousse
Wrong upload folder link was created by poussemousse
Hello,
I have installed and started to use your great Visforms extension and I have some trouble to get back uploaded files.

For the moment, the path is still "tmp", but in the data table, the link provided is :
mydomain/site/tmp instead of mydomain/tmp
Therefore the links are bad, and I am not able to receive the uploade files in recipient mails.

I have to manually change each link to get to the files, and it is a pity.
I am using visforms revision 3.5.5.

Thanks for you help,
Regards.

More
8 years 8 months ago #1957 by Administrator AV
Replied by Administrator AV on topic Wrong upload folder link
Hi,

thanks for your post.
First I want to point out, that I have not changed the code that manages the file upload and creates the links in a very long time. So no changes here for Visforms 3.5.x
As nobody has reported a similar problem ever and because I think that using file upload fields in Visforms is quite common, I think this is specific of your website and does not really have all it's origins in Visforms. But one can never be sure.

I would like to clarify some thing.
If a file is uploaded Visforms only stores the relative path information to the upload folder and the name of the uploaded file (which was renamed during upload) in the database. These values are stored in the database in the following format
Code:
{"folder":"tmp","file":"2015_04150018_55d5e16ca8caa.jpg"}
So the first step to check would be, to look into your database, not through the Joomla! Administration, but the real database with a mysql admin tool. Open the #__visforms_n table where n is the form id (if you have only one form most probably 1). Find the column where the information of the upload field is stored. Its name is composed from the character F and the field id (for example F5, if the upload field has the id 5). You should find a string as mentioned above in that field. Check, whether the "folder" is stored correct there. (It should be tmp and not site/tmp).
So if the folder is already incorrect in the database, the problem is situated in the code that creates the values which are stored in the database. In this case, please let me know, because this would help me to locate the source of the problem.

If not you have to know that everywhere where Visforms displays links to the uploaded files, these links are built from the information stored in the database. So if you find a link mydomain/site/tmp but in the database the "folder" was only tmp for this uploaded file then, the problem is caused by the code, that dynamically creates the links.

If that is so, I think I can see one piece of code that might not always work exactly as expected and you could try the following. Find the file administrator/components/com_visforms/helpers/html/visforms.php and the function
Code:
getUploadFileLink
in this file.
Replace
Code:
JUri::root() with JUri::base()
in this function (there are 2 occurences).
Does this solve the problem?

Are you sure, that the links in the receipt mails do not work, or did you just guess because the links displayed on the website are incorrect?

Please let me know, what you find out!!

Regards,
Aicha

:idea: I recommend you the new and up-to-date documentation for Joomla 4:
docs.joomla-5.visforms.vi-solutions.de/en/docs/
Most of this also applies retrospectively to Joomla 3.
Please only ask 1 question per topic :-).

:idea: Ich empfehle Dir die neue und aktuelle Dokumentation für Joomla 4:
docs.joomla-5.visforms.vi-solutions.de/docs/
Das meiste gilt rückwirkend auch für Joomla 3.
Bitte immer nur 1 Frage pro Thema stellen :-).

More
8 years 8 months ago #1958 by poussemousse
Replied by poussemousse on topic Wrong upload folder link
Dear Aicha,

thank you very much for your very detailed answer.
As long as I don't have access to the SQL Database (I have not all the rights yet), I have started performing your change.

Unfortunatly, I went too fast, and I have only perform the change on the first occurence.
As the result was still negative, I have discarded the change and now the link are correctly generated, and I can see them at the end of Recipient mail !!!

Now I would like to change the folder from "tmp" (tmp being at the root) to a new folder "foo1" for instance.
When I do this, I am not able to perform the save in Visforms, I always get the following error message :
Error, ..., Upload directory (advanced options) doesn't exist.

I have even tried to place this foo1 as a subfolder of tmp typing "tmp\foo1" in Uploaded Files Directory, the problem is persistant.

Note, I have put an index.html as mentionned, but it is said "empty", do we agree to say that I must keep the header line :
<!DOCTYPE html><title></title>.

Waiting for your feedback for next try,
Regards
Poussemousse

More
8 years 8 months ago #1960 by Administrator AV
Replied by Administrator AV on topic Wrong upload folder link
Hi,

the first step is to create the foo1 folder.
The second step is to change the path in the form configuration.
You always have to enter the full path to the folder insider your Joomla! root.

So if the folder foo1 is a subfolder of tmp you have to enter
Code:
tmp/foo1
I think your mistake was to use a backslash in the path instead of a forward slash (paths are always with a forward slash).

I hope this will help.

Regards
Aicha

:idea: I recommend you the new and up-to-date documentation for Joomla 4:
docs.joomla-5.visforms.vi-solutions.de/en/docs/
Most of this also applies retrospectively to Joomla 3.
Please only ask 1 question per topic :-).

:idea: Ich empfehle Dir die neue und aktuelle Dokumentation für Joomla 4:
docs.joomla-5.visforms.vi-solutions.de/docs/
Das meiste gilt rückwirkend auch für Joomla 3.
Bitte immer nur 1 Frage pro Thema stellen :-).

More
8 years 8 months ago #1968 by poussemousse
Replied by poussemousse on topic Wrong upload folder link
Aicha,
First of all, I confirm that path in the SQL database has always been correct.

Dealing with the ability to change of folder, even using the slash I always have the same error message. Note, in the tiptool text, you mention to use backslash, it will be something to change in the next revision.

Do you have any other idea to solve the problem ?
THXS
Poussemousse

More
8 years 8 months ago #1969 by Administrator AV
Replied by Administrator AV on topic Wrong upload folder link
Hi,

thanks for the confirmation of the correct path values in the database.

Because in the German and English language there is only a / mentioned in the tooltip text for the upload path option I got curious about what language your backend uses.

I cannot remember every code part of Visforms and because I did not change the code, that manages the file upload in a long time, I had to take a look into the original code myself.

The code that bothers you is part of the function check() in the administrator/components/com_visforms/tables/visform.php
Code:
$uploadpath = preg_replace('#\\\\#', '/', $this->uploadpath); $this->uploadpath = $uploadpath; //remove slashes at the beginning and the end of string $this->uploadpath = rtrim($this->uploadpath,'/'); $this->uploadpath = ltrim($this->uploadpath,'/'); $check = trim($this->uploadpath); if(!empty($check)) { $check = JPath::clean($check); if(!JFolder::exists($this->uploadpath)) { $directory = JPATH_SITE.'/'.$this->uploadpath; if(!JFolder::exists($directory)) { $this->setError(JText::_('COM_VISFORMS_DIRECTORY_DOESNT_EXISTS')); return false; } } } else { $this->setError(JText::_('COM_VISFORMS_DIRECTORY_EMPTY')); return false; }

As you can see, this code actually converts \ into / and removes / at the beginning and the end of the upload folder path string. So if you are really sure that you have typed in the correct upload path, I think the best way to find out what goes wrong would be to comment the part, that throws the error and so enforce to store the path into the database and then to look in the database what string is actually stored. Make a copy of the file first. You can always reset the path to tmp afterwards and return to the original visform.php file then.
Code:
/*if(!empty($check)) { $check = JPath::clean($check); if(!JFolder::exists($this->uploadpath)) { $directory = JPATH_SITE.'/'.$this->uploadpath; if(!JFolder::exists($directory)) { $this->setError(JText::_('COM_VISFORMS_DIRECTORY_DOESNT_EXISTS')); return false; } } } else { $this->setError(JText::_('COM_VISFORMS_DIRECTORY_EMPTY')); return false; }*/

Regards,
Aicha

:idea: I recommend you the new and up-to-date documentation for Joomla 4:
docs.joomla-5.visforms.vi-solutions.de/en/docs/
Most of this also applies retrospectively to Joomla 3.
Please only ask 1 question per topic :-).

:idea: Ich empfehle Dir die neue und aktuelle Dokumentation für Joomla 4:
docs.joomla-5.visforms.vi-solutions.de/docs/
Das meiste gilt rückwirkend auch für Joomla 3.
Bitte immer nur 1 Frage pro Thema stellen :-).

Moderators: Administrator AVAdministrator IV
Powered by Kunena Forum