Hello all. I have an issue when trying to read an uploaded file. The below error occurs on a new installation of web2Project version 3.1.0. I successfully attach a file on a task but I cannot read or download the file once it is uploaded. I can see that it is uploaded under the Files tab but I get the following error when I click on the file: \"An invalid file handle was passed to the function\". Can anyone help me on the above? Thank you.

asked 07 Apr '14, 05:13

creator403's gravatar image

creator403
0223
accept rate: 0%

edited 07 Aug '14, 12:44

opto's gravatar image

opto ♦
82341104131

Hi, I get the same error. would also appreciate some assistance.. regards Pieter

(11 Apr '14, 04:30) Makgone Makgone's gravatar image

Is this happening for files attached to Projects or any file uploaded?

(11 Apr '14, 10:55) caseydk ♦♦ caseydk's gravatar image

Same here. I've located the problem and made a temporary fix: I derped around with fileviewer.php, trying to find out where it fell apart. if (!$exists) { $AppUI->setMsg('fileIdError', UI_MSG_ERROR); $AppUI->redirect(); } Lines 104-107 in my copy. If you take out the setMsg part, you don't fix the problem, but you no longer get the \"an invalid file has been passed to the function\" message. This made me think that this if statement was being triggered for all files--basically, the viewer is being told that none of the files exist. Then I went to file.class, since $exists is a variable of fileclass, which is declared CFile. I checked the \"read\" and \"exist\" functions. This line is in read:\n$handle = fopen(W2P_BASE_DIR . '/files/' . (int) $project_id . '/' . $filename, 'rb'); This line is in exists:\n$fname = W2P_BASE_DIR . '/files/' . (int) $project_id . '/' . $filename; But I checked my file's URL, and it doesn't start with a project id, so I removed \". (int) $project_id . '/' \" from both lines. Now it opens as it should. I only tested this on one file because it's the only one uploaded at the moment. It is not attached to any projects, which might be why it was broken. It was broken when I had more files uploaded as well, though, all of which were attached to projects. I will attach this file to a project and see if it still works. Edit: It turns out that I was right about \"if (!$exists) { $AppUI->setMsg('fileIdError', UI_MSG_ERROR); $AppUI->redirect(); }\" being triggered for all files, but the other two lines, \"$handle = fopen(W2P_BASE_DIR . '/files/' . (int) $project_id . '/' . $filename, 'rb');\" and \"$fname = W2P_BASE_DIR . '/files/' . (int) $project_id . '/' . $filename;\" are both correct. The problem was that created files were being deposited in the Root folder, rather than the folder for each project ID. I fixed this without changing any code at all: Just manually add a \"0\" folder in the \"files\" folder, and new files will be added in their automatically. I did this while running the unedited code, and it worked perfectly.
permanent link

answered 05 Aug '14, 16:22

tywms4's gravatar image

tywms4
1121
accept rate: 100%

edited 07 Aug '14, 15:39

Can you check the files/ folder itself? Did your file end up in that folder specifically or within a folder called "0" ? There was a brief bug where files were put in the root when they should have been put in folder zero.. which is a bit off. :(

(06 Aug '14, 00:11) caseydk ♦♦ caseydk's gravatar image

My file ended up in Root, and there is no 0 file for project ID = 0. I believe that this was the problem. I changed the code back to what it was before and manually added a "0" folder in the Root folder. It seems that everything is working fine now--files upload to that folder by default and I can move them around if need be. Thank you!

(07 Aug '14, 11:34) tywms4 tywms4's gravatar image
Hello caseydk, This happens for any file uploaded, either it is attached to Projects or not.
permanent link

answered 11 Apr '14, 11:00

creator403's gravatar image

creator403
0223
accept rate: 0%

answered 11 Apr '14, 11:00

me too ;/
permanent link

answered 16 Apr '14, 14:31

ciochu's gravatar image

ciochu
(suspended)
accept rate: 0%

answered 16 Apr '14, 14:31

I had the problem with files when they were attached to projects, as soon as they were not assigned to projects I could view it, I replaced fileviewer.php with the latest version which can be downloaded [here][1] [1]: https://github.com/web2project/web2project/blob/master/fileviewer.php\nNot sure if this is the same thing or not.
permanent link

answered 25 Apr '14, 08:29

kareljj's gravatar image

kareljj
(suspended)
accept rate: 0%

answered 25 Apr '14, 08:29

Hello kareljj. I saw the code snippet and I noticed I was missing a line. I added that extra line and I still get the same error when I try to see the file.

(28 Apr '14, 04:32) creator403 creator403's gravatar image

Mine is definitely working, I create sub-folders in root, upload the documents and then attach it to projects. The documents are grouped with the projects and I can view them. Did you assign file-view rights to your users?

(28 Apr '14, 07:54) kareljj kareljj's gravatar image
I think this works in the stable 3.2pre version, see my other post (at least for files attached to projects, didn't try tasks). Subfolders don't work yet (file handle error). There is no new file button yet, but the dropdown in the upper right for new file works. Klaus
permanent link

answered 28 Apr '14, 07:44

opto's gravatar image

opto ♦
82341104131
accept rate: 10%

answered 28 Apr '14, 07:44

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×12
×4
×2
×1

question asked: 07 Apr '14, 05:13

question was seen: 1,508 times

last updated: 07 Aug '14, 15:39

powered by Bitnami OSQA