News:

SMF 2.1.3 has been released! Take it for a spin! Read more.

Main Menu

Attachments lost since SMF 2.0 to SMF 2.1.2 upgrade

Started by Ripi, June 16, 2022, 08:36:37 AM

Previous topic - Next topic

Ripi

Hello everybody,

I would like to ask for your help following a problem with my SMF forum. Following the update of the forum to 2.1.2, the display of attachments has disappeared. They no longer seem available, on clicking the message "File not found." appears. However these files are still on the FTP.

I already checked :
- permissions (755 folder / 644 files)
- folder attach paths with repair settings (all status and number of files are OK in the backoffice)
- binary transfer when I tried to re-upload some files

Important to notice : attachments still work, those integrated since the update are well displayed.
I verified the Wiki, and some related posts like simplemachines[dot]org/community/index.php?topic=579046.0 or simplemachines[dot]org/community/index.php?P=d85pkbbnpla0djmvh4nkb9oqre&topic=154832.20", unfortunately without success.

SMF version : 2.1.2
PHP version : 7.4
Example URL : forum-kayak[dot]fr/index.php/topic,16176.0.html
Exemple of file not found : forum-kayak[dot]fr/index.php?action=dlattach;attach=80059
On FTP : /public_html/forum-kayak[dot]fr/upload/files2020/80059_7137867ba19eedac1d8f7ff5f55dce6ae3760e7e

I remain at your disposal for any clarification that will help in the diagnosis.

Thank you in advance for your help, and congratulations for maintaining this usefull CMS.

Sir Osis of Liver

"The best laid schemes o' mice an' men / Gang aft a-gley." - Robert Burns

Ripi

Quote from: Sir Osis of Liver on June 16, 2022, 05:36:31 PMDo all attachments have a .dat extension?


Hello,

Thanks for your reply.
No, the old attachment don't have .dat extension.
It's not normal? Is there anything I can do to fix it?

Sir Osis of Liver

If you used 2.1 upgrade package and ran upgrade.php, all attachments should have .dat extension added to hashed filename and all attached avatars should have been moved to new /custom_avatar directory.  If those two things didn't happen, upgrade failed.  If you have a good 2.0 database backup, you can try running upgrade.php again.  If everything else is working in 2.1.2, you can add the .dat extension to all attachments manually, or, if there are a lot of them, with a php script.
"The best laid schemes o' mice an' men / Gang aft a-gley." - Robert Burns

Ripi

Hello,

First of all, a big thank you, you have identified the problem!
Indeed, the update does not seem to have worked correctly on this point (I checked, everything else is OK).

By renaming the files manually (I'll see if I can find a script, there are 65,077 files concerned  ;D ), the image is again accessible on the URL /index.php?action=dlattach;attach=XXXXX ;image
But, once the file name is corrected, the attachment no longer appears directly in the discussion as before. The only option is to click to download it.
Example here: hxxp:www.forum-kayak.fr/index.php/topic,14561.msg159036.html#msg159036 [nonactive]
Do you know if there is a way to force the previews to respawn please?

Thanks again for your assistance and have a nice day,


PS: I already cleared the SMF cache, no change.

Sir Osis of Liver

Upload attached file to forum root, run it once, it will add .dat extension to all files that don't have the extension.  You'll have to manually fix /attachments/index.php (I'm too lazy busy to include that in script).  Backup the directory before you run it.

Don't know offhand why embedded images are not being displayed in post, maybe someone else can answer that.  I gotta go ...........

"The best laid schemes o' mice an' men / Gang aft a-gley." - Robert Burns

MrPython

Quote from: Ripi on June 20, 2022, 08:24:20 AMBy renaming the files manually (I'll see if I can find a script, there are 65,077 files concerned  ;D ), the image is again accessible on the URL /index.php?action=dlattach;attach=XXXXX ;image

I also got trouble with the update. bash script helped, only index.php was also renamed  :)
#!/bin/bash

for file in *
do
 mv "$file" "$file".dat
done

Ripi

Thanks a lot to both of you !
I save the forum and I will launch the modification of the uploaded files.

I'll search the archives to see if this issue showing attachment previews is known.
If anyone has had this problem before, don't hesitate to send me the related topic.

Sir Osis of Liver

If the script fails, check your directory/files permissions.  They should be 755/644.
"The best laid schemes o' mice an' men / Gang aft a-gley." - Robert Burns

Ripi

It took a bit of time because I proceeded successively by directories ($directory = 'upload/files20XX/';...) but the script worked perfectly. All site attachments are functional again. Thanks a lot. 👍

Advertisement: