Community Support for OpenDocMan (Deprecated)

Full Version: Please upload a valid document. Error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
ztirffritz
2008-04-16 11:13:21 PDT
When I try to upload a document I receive this error: 'Please upload a valid document.' There is no further information.

I searched in the forums and it seems as if something is missing from the screen in my installation. There is no indication of the mime type that is needed. Just this error. I'm using Firefox as my browser, Ubuntu 7.10 as my server. I checked the php.ini file and uploads are allowed, max file size is 2M (well above the size I'm uploading). Where else would I look for errors?


jonathanwminer
2008-04-16 11:24:37 PDT
Hi -

Four files to double check:

/etc/mime.types
{ODM}/mimetypes.php (only used if /etc/mime.types doesn't exist)
{ODM}/config.php (look for $GLOBALS['allowedFileTypes'])
{ODM}/config_local.php (may override $GLOBALS['allowedFileTypes'])

Hope that helps... Which version of ODM are you running? What type of file is being uploaded?

- Jon


ztirffritz
2008-04-16 11:34:53 PDT
I'm trying to use PDF, OpenOffice Spreadsheets/WordProcessor/Presentation, MS Excel/Word/Powerpoint, jpg, HTML...

I've tried just about everything that I can think of and nothing has worked. I'm a bit concerned because the only major entry in the log files that I've noticed as suspicious is that 'setup.php' can not be found. I'm not sure where it should be, but I'm assuming that it is in either the 'Install' folder or the root of the application. I downloaded the install files twice thinking that maybe I received a corrupted version, but both were missing 'setup.php'. Installation seemed towork anyway, so I just plowed ahead. I'm using the latest version 1.2.5 I think.


ztirffritz
2008-04-16 11:38:31 PDT
I don't have a config_local.php file, just config_local.php.sample.


ztirffritz
2008-04-16 15:10:51 PDT
I created a 'config_local.php' file by copying the config_local.php.sample file. I modified the settings and uncommented the things that I needed, but it still won't let me add a document. I set the permissions on the repository folder to 777 some ANYONE can Read/Write/Execute/Delete the files there. It still doesn't work.


jonathanwminer
2008-04-17 06:24:19 PDT
FYI...

You don't need a config_local.php file... it's just there to provide a convenient place to store configuration variables so they don't get overwritten by new installs.


jonathanwminer
2008-04-17 06:41:41 PDT
My mistake about the mimetypes.

There are two cases that generate this error message. Look for "ec=11" in the code.

The first one is in add.php, if the filesize <= 0

The second one is in check-in.php, again if the filesize <= 0

I would check to see if the webserver has permission to write to the document repository. What user is the webserver running as? Check the webserver's access and error files. (Usually in /var/log/httpd)

On my Linux ODM server, the webserver runs as the "apache" user, and the document repository is owned by "apache" and rwx by user, rx by group and other.

drwxr-xr-x 4 apache apache 4096 Apr 15 08:47 document_repository

You might try to "su" to the webserver user and manually going into that directory and create a file.

(If you're running Windows... then good luck!)

-----------

The great thing about Open Source Software (OSS) is that you can actually look at the code and see where the error comes from. I'm not saying this to be sarcastic... but seriously, one of the best places to start looking to understand why an error is occuring is the source code. This is why OSS is far superior to Commercial Off The Shelf (COTS) software in many aspects.

ztirffritz
2008-04-17 10:17:06 PDT
Does the Document Repository NEED to be called 'Document_Repository'? I think that I just created a folder called 'data' at /usr/local/opendocman/. For now the permissions on it are '777' and it is owned by root:root. So long as the permissions are 777 it should be writable by any user. Once I get it working, maybe I'll go back and try to make it more secure.

Instead of '0' what should be here? '1'?

********************
The first one is in add.php, if the filesize <= 0

The second one is in check-in.php, again if the filesize <= 0
********************


jonathanwminer
2008-04-17 10:27:09 PDT
You can name the repository anything you want, as long as you edit either config.php or config_local.php and set the variable to the proper value, including a trailing slash:

In config_local.php, your entry should be something like:

$GLOBALS['CONFIG']['dataDir'] = '/usr/local/opendocman/data/';

Don't changes the zeros in those two files... they are correct.

Again... have you tried to "su" to the webserver user and create a file in the directory?


ztirffritz
2008-04-17 10:35:30 PDT
As for Open Source software, yes it is great...if you have time and the knowledge to search the source code. I currently have a little bit of time, but not the knowledge. I'm just fumbling along trying to figure this out. I see that there is a mimetype.php file that looks like it is reading in the entries from /etc/mime.types, so that shouldn't be the issue.


ztirffritz
2008-04-17 10:41:26 PDT
yes, I can create a file in the 'data' directory while logged in as root and as 'www-data'. I did this:
touch /usr/local/opendocman/data/test
nano /usr/local/opendocman/data/test

It let me create the file, edit it, and save the changes for both users.

My config.php file and the config_local.php both show the same thing for the variable 'dataDir', including the trailing '/'.

jonathanwminer
2008-04-17 10:44:32 PDT
What version of Linux are you running?


ztirffritz
2008-04-17 10:56:27 PDT
I found this reference to 'ec=11' in add.php:
**************
//can't upload empty file
if ($_FILES['file']['size'] <= 0 )
{
header('Location:error.php?ec=11');
exit;
}
***************

Does this mean that it is not correctly uploading my file that I'm selecting through the web browser? The file is definitely not empty. Why would it think that the file is empty?


ztirffritz
2008-04-17 10:58:00 PDT
Ubuntu Linux Server.


jonathanwminer
2008-04-17 10:59:23 PDT
Are files being created in your dataDir ?


ztirffritz
2008-04-17 11:04:04 PDT
No. What files should be in there? I saw some references to some archive and revision folders in the config.php file, but they don't exists in the dataDir.


jonathanwminer
2008-04-17 11:38:19 PDT
Should be two directories:

archiveDir
revisionDir

Both owned by the webserver user, and rwxr-xr-x. I'm not sure if those should have been created during setup or not... but I suspect they should have been.


ztirffritz
2008-04-17 11:44:32 PDT
The 'setup' routine just asks for the MySQL user with create permissions, then it asks for the username and password the for opendocman database. It doesn't ask for anything else. As I stated, earlier, there IS an error in the Apache logs stating that 'setup.php' is not found. I see that referenced in the documentation several times too, but I've searched all the files and there is no 'setup.php'. Where should this file be? It isn't included in the downloaded of ODM 1.2.5. I've downloaded the files twice from two differenct repos and neither included this file.


ztirffritz
2008-04-17 11:50:56 PDT
I created the directories, and set them to 751 as you indicated. They are owned by 'www-data' which is the equivalent of the 'apache' user in Ubuntu jargon.

I did a search again for setup.php and the only files by that name on my server are located here:
/usr/share/phpmyadmin/libraries/dbg/setup.php
/usr/share/phpmyadmin/scripts/setup.php

I'm assuming that neither of those are the file being called during the installation of ODM.


ztirffritz
2008-04-17 11:56:08 PDT
Correction, permissions are 755.


jonathanwminer
2008-04-17 11:59:08 PDT
The setup.php script gets deleted after it is run. That is a security feature, and prevents someone else from re-configuring your ODM installation. You might try unpacking a fresh installation, then looking in the "install" subdirectory.


ztirffritz
2008-04-17 13:12:43 PDT
I just tested on both the zip and the tar versions and neither included the setup.php file after they were un-packed. I don't know that this is the problem, but I'm getting suspicious about it.


jonathanwminer
2008-04-17 13:51:11 PDT
Based on reading the 1.2.5 source code, it appears that install/index.php is also known as "setup.php"

But I don't see any references to setup.php in any of the PHP files, only in the documentation. I'm not sure why you would see references to setup.php in your log files... Could it be that someone is accessing your box and trying to run setup.php?

ztirffritz
2008-04-17 14:02:50 PDT
I told you I was fumbling and bumbling...I just realized that this log entry was from me trying to manually run setup.php from the browser. I saw that in some forums and howtos that I was reading. I guess I can scratch that off of the list of what is wrong though.

Does OpenDocMan generate its own log files? Is there a way to turn on/off a log file for it? I'm stumped. If I manually put a file in the dataDIR location will it show up in the web browser? Is there a way to manually force a file into the software, just to see what happens?


jonathanwminer
2008-04-17 14:11:32 PDT
All the log messages should be in the the web server's error log.

Here is something to try... create the following PHP file, name it test.php, so something that doesn't conflict with any other file:

<html><body>
<?php
system("touch /tmp/testfile");
?>
</body></html>

When you try to load this file with your browser, ie, <!-- m --><a class="postlink" href="http://yourserver/test.php">http://yourserver/test.php</a><!-- m -->, it will attempt to create the file. In my case the file ends up being:

-rw-r--r-- 1 apache apache 0 Apr 17 17:06 testfile

Then try changing the pathname to the ODM repository directory and see if you can still create a file.


ztirffritz
2008-04-17 14:29:16 PDT
interesting...on my server it didn't do anything in /tmp, but it did create a file in /usr/local/opendocman/data/ when I changed the location in test.php.


jonathanwminer
2008-04-17 14:31:57 PDT
Well, the fact that it created a file in the data directory is good... rules out that as a possible problem.


ztirffritz
2008-04-17 15:47:33 PDT
OK, minor break-through....

I logged out of the interface then logged in again and it showed that I had 1 document waiting to be reviewed, but it showed an 'X' where the file size should be. I approved it and tried to open it, but it didn't work. I'm not sure what was different. When I tried to open the file these errors were shown:
***************************
Warning: filesize() [function.filesize]: stat failed for /usr/local/opendocman/data/1.dat in /var/www/opendocman/view_file.php on line 98

Warning: Cannot modify header information - headers already sent by (output started at /var/www/opendocman/view_file.php:98) in /var/www/opendocman/view_file.php on line 98

Warning: Cannot modify header information - headers already sent by (output started at /var/www/opendocman/view_file.php:98) in /var/www/opendocman/view_file.php on line 100

Warning: Cannot modify header information - headers already sent by (output started at /var/www/opendocman/view_file.php:98) in /var/www/opendocman/view_file.php on line 101

Warning: Cannot modify header information - headers already sent by (output started at /var/www/opendocman/view_file.php:98) in /var/www/opendocman/view_file.php on line 102

Warning: filemtime() [function.filemtime]: stat failed for /usr/local/opendocman/data/1.dat in /var/www/opendocman/view_file.php on line 104

Warning: Cannot modify header information - headers already sent by (output started at /var/www/opendocman/view_file.php:98) in /var/www/opendocman/view_file.php on line 105

Warning: readfile(/usr/local/opendocman/data/1.dat) [function.readfile]: failed to open stream: No such file or directory in /var/www/opendocman/view_file.php on line 106
********************************
The only one that means anything to me is the last one indicating that the file doesn't exist at the location.


ztirffritz
2008-04-17 15:57:18 PDT
I can't remove the document because it doesn't exist...geez.


ztirffritz
2008-04-17 16:24:26 PDT
I don't know if this was the correct way to fix that last problem, but I deleted the file from the DB using PHPMYAdmin. I removed the record from 'data' table.


ztirffritz
2008-04-17 17:04:07 PDT
Got it! PHP defaults to the /tmp folder for uploaded files. Our earlier experiment with test.php indicated that 'www-data' user did not have the ability to write to /tmp. It didn't click for me until I started looking at the configuration settings in WebMin for PHP5. I went back and set the security for /tmp to 777 and it worked. FINALLY. Thanks for all of the help and for patiently letting me stumble to the solution on my own. I probably learned more this way than I would have otherwise.


jonathanwminer
2008-04-21 06:55:34 PDT
Good... Interesting that /tmp wasn't 777 to begin with?

You may want to se the "sticky-bit" on /tmp:

chmod 1777 /tmp

This gives everyone access, but you can't delete someone else's files. Thats how most Linux systems are setup by default.