I try to upload a 14k html file, but get the following message:

# ser warning: Field 'fdesc' doesn't have a default value query: INSERT INTO webfm_file (fpath, uid, fsize, fcreatedate, perm, fmime) VALUES ('sites/default/files/documents/318365.htm', 1, 14561, 1225681896, 2, 'text/html') in C:\Apache2.2\htdocs\sites\all\modules\webfm\webfm.module on line 2538.
# Could not insert sites/default/files/documents/318365.htm into the database
# Insertion into database fail

I have tried it with another small msword file with same results.

I am running drupal on Apache/window xp machine.

Comments

lilon’s picture

I have found a similar problem from 2007 and the solution was to add the following to the dbinsert_file function in webfm.module:

$metadata['fdesc'] = '';

I tried it and it solved the problem.

According to the old post it was supposed to be added to the next version at the time. I wonder why it was taken out again?

Would appreciate comments

dmsmidt’s picture

Title: cannot upload » Can't upload | Insertion into database fail
Priority: Normal » Critical

I had the same issue. Also fixed it by inserting $metadata['fdesc'] = '';.
Seems critical to me.

Drupal 6.6

robmilne’s picture

The proper fix is in head and documented here:

http://drupal.org/node/327993

Rocketman’s picture

I am experiencing the same issue with Drupal 5.x and WebFM 5.x-2.15 on Windows with IIS6.

What is the fix for 5.x-2.15?

robmilne’s picture

Similar fix:

Replace line 18 of webfm.install with...
fdesc text NOT NULL default '',
...uninstall and reinstall

Unfortunately this will destroy the webfm_files and webfm_attach tables and all metadata and attachments will have to be recreated - not cool unless the site is virginal. The way to minimize damage would be to add this to webfm.install and run update.php:

function webfm_update_3() {
  $ret = array();

  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql("ALTER TABLE {webfm_file} DROP fdesc");
      $ret[] = update_sql("ALTER TABLE {webfm_file} ADD fdesc text NOT NULL DEFAULT ''");
      break;
  }

  return $ret;
}

This will destroy current descriptions but leave other data intact

Rocketman’s picture

I tried running update.php after making the changes to webfm.install but get this error:

webfm module
Update #3

* ALTER TABLE {webfm_file} DROP fdesc
* Failed: ALTER TABLE {webfm_file} ADD fdesc text NOT NULL DEFAULT ''

Even with this error the problem is now fixed and uploads are working.

Thanks for the help.

robmilne’s picture

Does the fdesc column still exist in your webfm_file table? I imagine it does if the module is working but the failed message is worrisome. A quick check with phpMyAdmin will confirm its existence.

meichr’s picture

The problem with the solution of adding a default value to a text field ist that some versions of MySQL 5 seem not to allow default values on text fields, see my comment in this issue.

Under version webfm-6.x-2.11 there is an implementation of the solution to set the field 'fdesc' to an empty string value '' if it would be NULL before the INSERT into the database. I suggest to backport this solution to 5.x-2.15 with the suggested patch of my comment here.

meichr’s picture

Version: 6.x-2.10-rc2 » 5.x-2.15

As this issue is solved for webfm-6.x-2.11 I move it to the version wenfm-5.x-2.15 to address the existing necessity of the patch there. Hope this is ok.

nhck’s picture

As per #803722: Cease support of Drupal 5? support for D4 and D5 has been closed. Sorry, please upgrade to Drupal 6. If you think this issue still applies with Version 6.x please reopen this issue with correct version tag.

Thank you! :-)

nhck’s picture

Status: Active » Closed (won't fix)