View Full Version : invalid attachment problem
Macsee
05-10-2012, 03:22 PM
When I click on the image in posts, I get the error message
"invalid Attachment specified. If you followed a valid link, please notify the administrator"
This is something I've noticed over the last few weeks.
Strange thing is that someone created a post with an attachment a few days ago and it worked the first time I tried it. But when I go back to that post now I get the error message.
This seems to affect only the private forum (Admin CP > Forum Manager > Show Private Forum = Yes, Display Post Count).
I've tried a site: search in Google to see if the problem has come up before on these forums, and I've found a few threads about the issue, but no solution.
Any suggestions?
Lynne
05-10-2012, 03:36 PM
Are your attachments stored in the database or filesystem? Can you look in the filedata/attachment table and actually see the attachment? Do you allow users to delete their attachments? And do you have a limit on the amount of space a user may use for attachments? Are you sure they are not deleting it via their own Settings page?
Macsee
05-10-2012, 05:40 PM
Good suggestions ... and you had me scrambling around looking for things! :)
First, the images are in a database (but I don't know how to look in the attachment table to see the attachment. A mySQL query?)
I'd rule out users deleting attachments intentionally, I've spoken with my employees who have accounts on the forum. Besides, I've checked now and, no, they don't have permission to delete.
The space limit is interesting and not one I had considered. I don't believe I've set a limit, but how would I check? There does not seem to be this space limit setting in the Attachments section of the usergroup and the settings in Options > Message Attachment Options has the "Limit Space Taken Up By Attachments" set to 0. Is there some other location I need to be investigating?
Lynne
05-10-2012, 09:29 PM
Space limit is a usergroup option. The one you see in settings is the overall site space limit. But, if you look in the Usergroup Manager, you will see if you set a space amount for that usergroup.
If you look at the link for the attachment, somewhere it should say "attachmentid=xx". You may then look in the attachment table and see if there is a row where attachmentid equals xx. That will tell you if the attachment exists still. Now, in that same row, please note the filedataid for that attachment. I'll call that zz.
Does that link have anything in it like "thumb=yy" ? If so, what? Now, look in the table filedata and see if you can find a row for filedataid zz. Does it have a BLOB size larger than 0 under the field thumbnail?
You said this is only happening in a private forum? So, there is no way we can get a link to a post where you are having the problem?
Macsee
05-11-2012, 10:10 AM
Thanks, Lynne.
I have an entry in the usergroup for "Space (in bytes) that a user's total attachment usage may consume - (Set to 0 to not have a limit) " and I have that set to zero.
Do you have a link to any tutorial on what I need to do to "look in the table". I have phpmyadmin access and FTP access and can download the db to my hard disk, but don't know how to search within the table. Can I open the relevant table in something like Excel?
I have noticed the problem so far only in the private forum. I could create a login for you to access that if you want and send it to you by PM.
If you run phpmyadmin, you should be able to select the database, click on the attachment table, then the "Browse" tab and scroll through the records. If you have a lot of attachments you'll probably want to do a query instead: click on the SQL tab and change the end of the query so that it looks like:
SELECT * FROM `attachment` WHERE attachmentid = xx
(obviously you want to put the actual attachment id in place of xx).
Lynne
05-11-2012, 02:32 PM
As Kevin said, phpMyAdmin is what you would use to look in your database.
rodeojones
05-14-2012, 04:04 PM
I have the same problem. I have a certain usergroup that can access a CMS page that has a link to an attachment. When I am logged in as administrator I can download the attachment just fine so I know the attachment is there. But when I log in as the other usergroup that can access the file I get the error "Invalid Attachment specified..."
I have verified the permission settings. Any help would be greatly appreciated. Thanks :)
EDIT: Ok, so I figured out my problem. I had added the attachment to a forum that my usergroup couldn't access and then used that URL for the attachment to the link on my CMS page. When I went in and posted the attachment in a thread my usergroup could access and then used that URL for the attachment, the link it worked just fine. As usual, user operated error :( Hope this helps anyone with a similar problem though.
Macsee
05-15-2012, 08:47 AM
Thanks for your replies, kh99 and Lynne. I'm away for a few days and don't want to log into pma on an insecure IP. I'll try the above when I get back home and I'll report back on the outcome.
smoking zone
05-15-2012, 09:38 AM
i need help off someone asap my members or i cant upload anything on the forum and the post and attachment size is 25mb i tried uploading 10mb but it says to much to process and then it says then whe i try upload it says image upload failed sh/identity no such file or directory but havent had any replys so dont know what to do can you help please also the uploader isnt the vbulletin select and upload it different for some reason
Macsee
07-11-2012, 01:45 PM
If you look at the link for the attachment, somewhere it should say "attachmentid=xx". You may then look in the attachment table and see if there is a row where attachmentid equals xx. That will tell you if the attachment exists still. Now, in that same row, please note the filedataid for that attachment. I'll call that zz.
Does that link have anything in it like "thumb=yy" ?
The attachmentid=100 exists in the db table. There's also an entry for filedataid in that row but it has a different number.
The link is in the form of [ATTACH=xx] and there is no thumb= element to it.
Lynne
07-11-2012, 05:18 PM
The thumb=yy I am talking about is in the source code of the page.
Macsee
07-13-2012, 10:50 AM
The source code is in the form of
<a href="http://myforums.com/attachment.php?attachmentid=137" title="Name:
Views:
Size: ">Attachment 137</a><br />
This is driving me nuts :(
I've spent all morning trying various things. I've logged on as one of the users who has several times in the past used attachments in his posts which are now leading to the invalid attachment message. I've created posts using his ID and added attachments to those posts.
I then had a look in the database. A couple of his attachments have a long entry in the posthash column of the attachments table. Example: c894c3d7090186aab36092639773d91f. Any idea what that is about? (Those show up with attachmentIDs in the tables, but with contentID of "0").
At least one of his old attachments seems to have completely disappeared from the database (the relevant number isn't in the attachmentID column). How could an attachment disappear from the database? I think this is the biggest problem.
Lynne
07-13-2012, 04:17 PM
If I recall correctly, the posthash column is used when the attachment is initially being attached. Once the post is actually posted (which includes posting the attachments), then that posthash should be removed. Any attachment with something in the posthash column should give an Invalid Attachment message (I am pretty sure) because the attachment was never actually posted validly (is that a word?!?!).
Macsee
07-16-2012, 10:07 AM
Thanks, Lynne. Any idea why causes attachments to disappear from the database? It seems to be not just my forum, I've found a few threads on this both here and in vbulletin.com (some are complaints about attachments getting deleted, but some are the practical implications i.e. attachments in posts not working).
I'm aware of the time limit users have - once an attachment has been uploaded it needs to be inserted in a post with a certain time frame (I think it's an hour). The attachments that disappear seem to be ones that have been inserted and used in posts.
Lynne
07-16-2012, 02:54 PM
I knew a guy who was having missing attachments, but only of certain types (not the .torrent files, only all others)! It was odd. I don't know if he ever figured it out. I had always figured someone was hacking him directly but never got server logs to look into it. But, it is something to consider.
Macsee
07-17-2012, 08:31 AM
OK, someone has just posted an attachment in the last five minutes which lets me observe what's happening.
If I click on the attachment link I can see the attachment. But I know it's going to disappear (ALL this user's attachments disappear).
So I've quickly logged in to PMA to see what the table is showing at the current time. The unusual markers are 1) there is an entry in the posthash column and 2) the contentID column says 0. Also, for some reason, this isn't the last record. It's placed six places from the bottom and is followed by lower numbered attachments from last week.
--------------- Added 1342521303 at 1342521303 ---------------
And now the attachment is gone!
There is no entry in the database with that number!
Invalid Attachment specified. If you followed a valid link, please notify the administrator
Arrghh!!
Lynne
07-17-2012, 03:54 PM
That all sounds very odd.
Have you tried totally disabling ALL your modifications and then having this user add an attachment and viewing what happens?
Macsee
07-17-2012, 05:30 PM
Thanks for staying with me on this, Lynne.
I keep talking about this user, but I don't believe it's unique to him. It's just that he uses attachments sometimes and almost nobody else does!
I don't have many mods and just a very few pretty standard plugins - Thank You hack/GlowHost/Easy Forms. I did consider disabling all of those when I took over this user's account to do some testing last week, but there didn't seem any point turning off the plugins as the problem precedes the installation of the plugins.
BTW, I don't know if it's relevant, but the only attachments anyone ever makes at my forum are images (png, jpg, gif).
Lynne
07-17-2012, 06:00 PM
Do you have a test site - a duplicate of your live site? It may be easier to do these sort of tests on a test site and be able to leave the live site alone.
Macsee
07-17-2012, 07:43 PM
I could create one in the next day or two and give you private access if you want.
Lynne
07-17-2012, 10:02 PM
I would set up a test site and see if you can reproduce the issue there. Then see if disabling all your modifications will 'fix' the issue.
Macsee
07-18-2012, 09:43 AM
Do you have a test site - a duplicate of your live site? It may be easier to do these sort of tests on a test site and be able to leave the live site alone.
As I said, I'm happy to create a test site for you to try out if you want.
Otherwise I don't get your suggestion. You seem to be suggesting that I create a test site to test this attachment problem, but I'm unable to see how testing on a test site is going to unearth something I haven't found by testing on the live site (which I've already done). Am I missing something?
I have tried turning off the modifications this morning and trying out some attachments. I get the same problem.
I'm beginning to suspect it's a vBulletin problem rather than one of my making. :(
Lynne
07-18-2012, 04:15 PM
OK, you may do tests on the live site.
I would suggest reuploading ALL totally default files for your site (important!), removing any files that are unused (very important!), setting your site to use a totally default style, and disabling all your modifications. Run your site like this for a few days. I thought that would be easier for you on a test site than on a live site.
Macsee
07-19-2012, 09:57 AM
Yes, such drastic action would hamper the smooth operation of the forum and would need to be done on a test site rather than the live one.
It is a fair amount of work and time commitment though. If I knew for sure this would solve the problem I would do it. However, considering that the problem is more deep rooted and possibly even a vB problem rather a Macsee one, I could end up sinking a lot of time and energy into chasing shadows.
I'm going to give up at this point. Thanks for all your assistance.
Simon Lloyd
07-19-2012, 10:17 AM
Maybe you have a messed up .htaccess file or hotlink protection in cpanel is messed up.
Lynne
07-19-2012, 04:05 PM
I really don't think it is a vB problem because you would be hearing a LOT of admins complaining about this happening on their site if it was a vB problem. As it is, I've only heard of this happening on a couple of sites and they all had modifications on them (and I think they were also on shared hosting).
Macsee
07-19-2012, 06:04 PM
Simon, that's a thought, but wouldn't a messed up htaccess affect all attachments including all that I, the admin, make? There is no cPanel on my server. Thanks for the suggestion though.
Lynne, I have seen a fair few complaints here, elsewhere and in vbulletin.com (in fact, one of their developers' attachments - posted in a thread about missing attachments, ironically - went walkabouts). I didn't save all the URLs but there were several.
Incidentally, I'm not on a shared host, it's a dedicated Linux/Apache box (and, yes, without cP). I've disabled EasyForms now and have only GlowHost and ThankYou. I dislike modding for precisely this reason - muddying the waters when it comes to troubleshooting - so no custom mods, not even our own skin. We use default vB.
Simon Lloyd
07-19-2012, 06:14 PM
Simon, that's a thought, but wouldn't a messed up htaccess affect all attachments including all that I, the admin, make? There is no cPanel on my server. Thanks for the suggestion though....No it wouldn't, here's a section that allows only certain domains to see or link to pictures#RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F,NC]
RewriteCond %{HTTP_REFERER} !^http://www.thecodecage.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.thecodecage.com$ [NC]
#RewriteCond %{HTTP_REFERER} !^http://www.thecodecage.com/forumz/.*$ [NC]
#RewriteCond %{HTTP_REFERER} !^http://www.thecodecage.com/forumz$ [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F,NC]
take a look in your .htaccess for something like this and see what's lurking there, other than server settings this is the only reason i can see for an upload to not complete!
I think Lynne was hinting at this before, but anyway - the cleanup2 scheduled task removes any entries from the attachment table that are older than 1 hour and have contentid = 0. So the fact that you saw the record had contentid=0 seems to be the problem. In includes/class_dm_threadpost.php around line 526 is this code:
if ($this->info['posthash'] AND $this->fetch_field('attach') AND $postid)
{
$this->dbobject->query_write("
UPDATE " . TABLE_PREFIX . "attachment
SET
contentid = $postid,
posthash = ''
WHERE
posthash = '" . $this->dbobject->escape_string($this->info['posthash']) . "'
AND
userid = " . intval($this->fetch_field('userid', 'post')) . "
");
}
That's suppose to be executed at the same time that the post is posted, to set the content id to the postid and to erase the posthash. It might be interesting to know if that's getting executed (when someone posts with an attachment), and if not, why not (which part of the condition is false). Since you have full access to your server you could do something like put in some code to open a debug file and write out some info (which is how I do a lot of debugging).
Macsee
07-19-2012, 07:01 PM
Simon, true. I had another look at htaccess. There isn't any rewrite for images and there's no blocking of hotlinking of images, nothing except a www canonical rewrite.
I think Lynne was hinting at this before, but anyway - the cleanup2 scheduled task removes any entries from the attachment table that are older than 1 hour and have contentid = 0. So the fact that you saw the record had contentid=0 seems to be the problem...
That makes sense. It appears that the contentid shouldn't be equal to 0 and I don't know what's causing it to default to zero.
I've opened the class_dm_threadpost.php file and the code you posted is in there starting exactly at 526. I wouldn't know how to go about the debugging though and I hate to impose any further.
Macsee
09-20-2012, 09:27 AM
As I've stated before, I'm not alone and this is a problem that keeps coming up. Today I found the below explanation from this webmaster forum (http://experienced-people.net/forums/content.php/393-Adding-attachments-process) (reproduced here via the Creative Commons permission they have given on this page (http://experienced-people.net/forums/showthread.php/9608)). The problem seems to be how images are attached. Using the WYSIWYG interface in vB is what seems to cause the problem and the advice is to avoid it.
vB provides two methods for attaching a file to a post (through three different actions). Please be aware that one method works consistently, and the other has had ongoing problems (causing vB boards to purge attachments).
In brief, if you are adding an attachment to a post, click on the Go Advanced button shown under the Quick Reply post entry area. Do not use the Insert Image icon shown at the top of the Quick Reply area, also shown at the top of the post area when clicking on Edit Post.
If your attachment is a graphic and is displayed in your post as a graphic, you have added it correctly. If you have attached another files type, such as a spreadsheet or Zip file, the name of the file should be shown.
If your attachment appears as text, such as:
Attachment 403
you will need to edit your post. Any attachments displayed in a post with the word, attachment, followed by a number, have not been added to a post.
Attachments not used in a post are purged by vB after one hour; Your attachment must be displayed within your post to prevent vB from removing it.
This is all the information needed (if you are familiar with vB use). Greater detail is below.
The correct button to use when adding attachments in vB is below the post entry area (for both the Go Advanced entry screen and the Edit Post entry page), and is named Manage Attachments.
There are two ways to access this tool when making posts to vB. Clicking on 'Go Advanced' to make a post will enable access to the tool. After a post has been made, clicking on Edit Post will also give you access to the tool.
To add a file:
1. Click on Manage Attachments.
2. Click on +Add Files (in the upper right). A dialog allowing you to Select Files is shown.
3. Clicking on Select Files to show files on your computer.
3a. Clicking on Basic Uploader, then Browse, will also allow selection of a file from your computer.
4. Navigate to the directory holding the file you wish to attach
5. Click once to highlight and then click on Open (or double-click the file).
5a. This will show the file name in your Upload Files dialog.
6. Click on Upload Files to add the file to your File Upload manager under Attachments.
7. In the lower attachments area, the file should be accompanied by a tick in a box. If not, click on Insert Inline.
8. Click on Done to complete the process, and close the tool.
Your attachment will be placed wherever your cursor was placed (in your post) when you entered this Manage Attachments tool. (Position can be changed by moving the vB ATTACH code.)
(Please also be aware that this tool does not allow files to be stored for future use. Uploads not utilized within one hour will be deleted. Uploads that are not stored properly are also deleted within an hour.)
Lynne
09-20-2012, 02:48 PM
I add attachments all the time just using the image button in the Quick Editor and my attachments are still around.
ICC FORUM
09-20-2012, 05:26 PM
I add attachments all the time just using the image button in the Quick Editor and my attachments are still around.
As of Yesterday my members can no longer use the Image Button to add Images, I was previously doing it this way also. The Only way i can use the Quick Editor function is to then click on the Basic upload function..
This is Very Annoying , Is there a Quick Fix for this as i am getting asked by my Members OR is this a VB Gremlin that they are looking in to..
All Images remain once Added , They Never disappear
Lynne
09-20-2012, 10:15 PM
Please start your own thread since your issue isn't covered in this thread at all and it will only get confusing discussing two different issues in the same thread.
mrfarmdog
02-16-2013, 07:50 PM
I have the same problem. I have a certain usergroup that can access a CMS page that has a link to an attachment. When I am logged in as administrator I can download the attachment just fine so I know the attachment is there. But when I log in as the other usergroup that can access the file I get the error "Invalid Attachment specified..."
I have verified the permission settings. Any help would be greatly appreciated. Thanks :)
EDIT: Ok, so I figured out my problem. I had added the attachment to a forum that my usergroup couldn't access and then used that URL for the attachment to the link on my CMS page. When I went in and posted the attachment in a thread my usergroup could access and then used that URL for the attachment, the link it worked just fine. As usual, user operated error :( Hope this helps anyone with a similar problem though.
Thank you for posting this. I was having the same issue and you helped me solve it!
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.