1

I am using K2 for content managing. In order to upload files I had to set /media/k2 directory's and its subdirectories' to 775. So, of course the web site has been damaged because of www-data group settings. That is a really bad experience but taught me so much.

My directories' owner was zkanoca and gorup was www-data. I have deleted the whole files and directories and uploaded from backup. I have set CHMOD values to 755 for directories and 644 for files as recommended.

This error occurs when a user tries to upload a profile picture too. It adds the user profile image file name into database but does not upload the file to media/k2/user directory.

For the restored web site the owner is zkanoca and the group zkanoca.

Then I have entered FTP information to Global Configuration page in administrator panel.

I have tried to upload some files using Joomla's Media Manager, it resulted well with no problem.

But when I try to add some attachments to a K2 item, it says it has uploaded and lists them in a table but actually it does not upload. It just insert a new record to k2_attachments table but does not upload the file to /media/k2/attachments. When I click on the file link on front side of the site, a message shows up K2_FILE_DOES_NOT_EXIST. But in the upload process it does not give any error.

If I add attachment to an item using K2, it adds records to database but not uploads the file. Then if I upload manually it works.

Another funny thing, if I upload the file first and add it as attachment to an item, it gives the same error message above.

I want to know how to upload files to K2 items with FTP settings. Because as far as I see it uses HTTP not FTP for files to upload.

I have tried one more thing but it did not help neither. I have changed the attachments folder to another. Again it could not write the file into the directory. So this means there is something wrong with K2's procedures.

1

Maybe you installed K2 before deciding to use the FTP interface?

When an extension is installed using apache interface all the files and directories created during the installation are owned by the apache user. Typically the FTP user will not have the write permission on them. The fix is to change owner to correct value.

chown will fix this if you can use it. Otherwise the simplest fix is to take a backup of joomla files and then restore it with the correct owner. Using FTP for example.

Still the first step should be to go to media/k2 folder and see if you can write there using FTP and can you fix it by downloading the folder, removing the folder, and restoring it. (Or chown but..)

  • That's a nice clue. I forgot to mention about user and group settings. Please read my revised post again. – zkanoca Jan 21 '15 at 7:15
  • After reading your answer few times more, I think I have already done those you suggest. – zkanoca Jan 21 '15 at 9:27
  • @zkanoca So basically my answer was useless in solving the problem, but useful in improving the question... I guess that is okay. – Ville Niemi Jan 21 '15 at 10:19
  • @zkanoca Does this happen in all browsers and all filetypes? Do you have SEF on? – Ville Niemi Jan 21 '15 at 10:34
0

Have you tried:

I edited the file administrator/components/com_k2/lib/class.upload.php and set MIME detection methods to false :

// these are the different MIME detection methods. if one of these methods
// doesn't work on yoursystem, you can deactivate it here; just set it to false
$this->mime_fileinfo = false; // MIME detection with Fileinfo PECL extension   
$this->mime_file = false; // MIME detection with UNIX file() commaed
$this->mime_magic = false; // MIME detection with mime_magic (mime_content_type())
$this->mime_getimagesize = false; // MIME detection with getimagesize()

This resolved the issue

  • I was too happy to find another solution proposal. I have changed those values to false but nothing has changed :( – zkanoca Jan 23 '15 at 13:16
  • I have also changed other settings. Still not working. I am dead sure that the problem is about CHMOD values and about K2 does not use FTP settings. – zkanoca Jan 23 '15 at 13:46
  • @zkanoca You might be right. I previously found an article about how the library K2 uses for upload is incompatible with FTP. I haven't been able to find it again, which is why I can't link to it or make an answer based on it, but I definitely saw it. (Trying to find it actually resulted in a hit that was a word-for-word copy of my first answer... LOL.) – Ville Niemi Jan 23 '15 at 14:20
  • @zkanoca Have tried changing the folder to apache/www-data or whatever apache uses? That would confirm it is a permissions issue. – Ville Niemi Jan 23 '15 at 14:26
  • I have just changed group as www-data and it works now. But this is not the solution I desire. Anyway, for a while I will go with this solution. – zkanoca Jan 23 '15 at 15:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.