CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • Error when attempting to upload file
Pages: [1]

Author Topic: Error when attempting to upload file  (Read 975 times)

FadeOUT

  • I post occasionally
  • **
  • Posts: 69
  • Karma: 0
  • IT Development at UK Charity
  • CiviCRM version: 4.1.3
  • CMS version: Drupal 7.14
  • MySQL version: 5.1.57-community
  • PHP version: 5.3
Error when attempting to upload file
August 17, 2012, 08:08:21 am
I don't know if this is unique to Windows, but I'm getting an error when trying to upload files - this case from a custom field on the Contribution screen:

Warning: rename
(C:\inetpub\wwwroot\CiviCRM\sites\default\files\civicrm\custom\egcsv_2491da39e3c5e8a85c588de3aee16776.csv,
C:\inetpub\wwwroot\CiviCRM\sites\default\files\civicrm\custom\C:\inetpub\wwwroot\CiviCRM\sites\default\files\civicrm\custom\egcsv_2491da39e3c5e8a85c588de3aee16776.csv):
The filename, directory name, or volume label syntax is incorrect.
(code: 123) in CRM_Core_BAO_CustomField::formatCustomField() (line 1669 of C:\inetpub\wwwroot\CiviCRM\sites\all\modules\civicrm\CRM\Core\BAO\CustomField.php).

What appears to be happening here is that the second rename parameter has the directory path twice.

Has anyone else seen this? I'll try to fix it. I'm using Windows / IIS, so my circumstances may be unusual.

FadeOUT

  • I post occasionally
  • **
  • Posts: 69
  • Karma: 0
  • IT Development at UK Charity
  • CiviCRM version: 4.1.3
  • CMS version: Drupal 7.14
  • MySQL version: 5.1.57-community
  • PHP version: 5.3
Re: Error when attempting to upload file
August 17, 2012, 08:32:22 am
Heh, it does an explode on the filename, using a "/"... While Windows uses a "\"... That's probably all there is to it!

Simply switching out the "/" for a "\\" doesn't seem to work, though. I'll have to take a close look. To be honest, it looks a bit grim in there - I seem to recall some slightly cleverer PHP file handling functions that should do this kind of thing automatically.

I'll look into it...

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Error when attempting to upload file
August 17, 2012, 09:44:14 am

yep, seems like we need to fix this for windows. We only need the filename, and should probably use a php function ratther than doing an explode

maybe: http://www.php.net/manual/en/function.pathinfo.php is a better function to use?

and then get the filename from there

wanna try the above out?

thanx

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

FadeOUT

  • I post occasionally
  • **
  • Posts: 69
  • Karma: 0
  • IT Development at UK Charity
  • CiviCRM version: 4.1.3
  • CMS version: Drupal 7.14
  • MySQL version: 5.1.57-community
  • PHP version: 5.3
Re: Error when attempting to upload file
August 20, 2012, 12:21:58 am
Ah, that looks like the one..!

I'll try it now :-)

FadeOUT

  • I post occasionally
  • **
  • Posts: 69
  • Karma: 0
  • IT Development at UK Charity
  • CiviCRM version: 4.1.3
  • CMS version: Drupal 7.14
  • MySQL version: 5.1.57-community
  • PHP version: 5.3
Re: Error when attempting to upload file
August 20, 2012, 12:58:42 am
Yes, that works fine:

Code: [Select]
  //$path = explode('/', $fName);
  //$filename = $path[count($path) - 1];
 
  $filename = pathinfo($fName,PATHINFO_FILENAME);

The PATHINFO_FILENAME option was only added in PHP v5.2 - I could rewrite it with a different function if there's a requirement to support older versions?

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Error when attempting to upload file
August 20, 2012, 08:17:17 am

Can you please file an issue with this patch. Using that function is fine. 4.2 requires php 5.3 for quite a few things

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

FadeOUT

  • I post occasionally
  • **
  • Posts: 69
  • Karma: 0
  • IT Development at UK Charity
  • CiviCRM version: 4.1.3
  • CMS version: Drupal 7.14
  • MySQL version: 5.1.57-community
  • PHP version: 5.3
Re: Error when attempting to upload file
August 20, 2012, 08:26:46 am
Will do - cheers.

FadeOUT

  • I post occasionally
  • **
  • Posts: 69
  • Karma: 0
  • IT Development at UK Charity
  • CiviCRM version: 4.1.3
  • CMS version: Drupal 7.14
  • MySQL version: 5.1.57-community
  • PHP version: 5.3
Re: Error when attempting to upload file
August 20, 2012, 09:01:33 am
Submitted: http://issues.civicrm.org/jira/browse/CRM-10688

Lobo - perhaps you could critique this submission; could I have made a better job of this? I left the file extension off the patch for some reason (I hope that's not a problem), but otherwise..?

Thanks.
« Last Edit: August 21, 2012, 01:25:29 am by FadeOUT »

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • Error when attempting to upload file

This forum was archived on 2017-11-26.