Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-03-28 13:12:42

masa
Member
From: North Wales, UK
Registered: 2005-11-25
Posts: 1,095

Problems uploading images or files, creating thumbnails

I’ve installed Txp on a new host. Everything seemed to work well, diagnostics OK, but for some obscure reason I’m unable to upload images or files.

The image seems to go, but never appears in the images tab – no error messages.
Same goes for files, although here I get the message “Failed to upload file test.txt – “.

I can access and edit all textual content just fine.

I noticed another oddity: when I tried to create a thumbnail for “divider.gif”, the only image in my db, I get the following error message if I only supply either width or height leaving the other field empty.

Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /srv/vefir/fyrirt/landslag.is/www/textpattern/lib/class.thumb.php on line 211
Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /srv/vefir/fyrirt/landslag.is/www/textpattern/lib/class.thumb.php on line 212
Warning: imagesx(): supplied argument is not a valid Image resource in /srv/vefir/fyrirt/landslag.is/www/textpattern/lib/class.thumb.php on line 363
Warning: imagesy(): supplied argument is not a valid Image resource in /srv/vefir/fyrirt/landslag.is/www/textpattern/lib/class.thumb.php on line 363
Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /srv/vefir/fyrirt/landslag.is/www/textpattern/lib/class.thumb.php on line 366
Warning: imagecopy(): supplied argument is not a valid Image resource in /srv/vefir/fyrirt/landslag.is/www/textpattern/lib/class.thumb.php on line 377
Warning: imagecopymerge(): supplied argument is not a valid Image resource in /srv/vefir/fyrirt/landslag.is/www/textpattern/lib/class.thumb.php on line 378
Warning: imagecopymerge(): supplied argument is not a valid Image resource in /srv/vefir/fyrirt/landslag.is/www/textpattern/lib/class.thumb.php on line 379
Warning: imagecopymerge(): supplied argument is not a valid Image resource in /srv/vefir/fyrirt/landslag.is/www/textpattern/lib/class.thumb.php on line 380
Warning: imagecopymerge(): supplied argument is not a valid Image resource in /srv/vefir/fyrirt/landslag.is/www/textpattern/lib/class.thumb.php on line 381
Warning: imagecopymerge(): supplied argument is not a valid Image resource in /srv/vefir/fyrirt/landslag.is/www/textpattern/lib/class.thumb.php on line 382
Warning: imagecopymerge(): supplied argument is not a valid Image resource in /srv/vefir/fyrirt/landslag.is/www/textpattern/lib/class.thumb.php on line 383
Warning: imagecopymerge(): supplied argument is not a valid Image resource in /srv/vefir/fyrirt/landslag.is/www/textpattern/lib/class.thumb.php on line 384
Warning: imagecopymerge(): supplied argument is not a valid Image resource in /srv/vefir/fyrirt/landslag.is/www/textpattern/lib/class.thumb.php on line 385
Warning: imagetruecolortopalette(): supplied argument is not a valid Image resource in /srv/vefir/fyrirt/landslag.is/www/textpattern/lib/class.thumb.php on line 238
Warning: imagegif(): supplied argument is not a valid Image resource in /srv/vefir/fyrirt/landslag.is/www/textpattern/lib/class.thumb.php on line 240
Warning: imagedestroy(): supplied argument is not a valid Image resource in /srv/vefir/fyrirt/landslag.is/www/textpattern/lib/class.thumb.php on line 256

I’m lost has anyone seen this before?
Any help would be very much appreciated!

Cheers Martin

(I’ve also been talking to the host, but they have yet to get back to me.)

Last edited by masa (2008-03-28 13:28:49)

Offline

#2 2008-03-29 13:41:46

feezenfreezen
New Member
Registered: 2008-03-29
Posts: 4
Website

Re: Problems uploading images or files, creating thumbnails

I have recently updated to textpattern 4.0.6 and on several sites I have encountered exactly the same problem… I can not upload images – after clicking “upload” nothing happens.

I would be happy about any hint

Best regards,
Fritz


/// blog ///

Offline

#3 2008-03-29 14:23:13

feezenfreezen
New Member
Registered: 2008-03-29
Posts: 4
Website

Re: Problems uploading images or files, creating thumbnails

After a little more research I have found the solution: The problem – at least in my case – was the temp-directory.
What you have to do is delete the tmp-folder settings under admin > preferences > advanced

and let textpattern find an adequate folder. It is explained in this FAQ


/// blog ///

Offline

#4 2008-03-29 15:09:10

masa
Member
From: North Wales, UK
Registered: 2005-11-25
Posts: 1,095

Re: Problems uploading images or files, creating thumbnails

I had tried that, but to no avail. Permissions are fine, too.

However in the PHP configuration I discovered that allow_url_fopen is set to Off. Could that be the culprit?

Sorry, this is really over my head. :-(

Offline

#5 2008-03-29 16:07:12

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Problems uploading images or files, creating thumbnails

Martin, can you post your full diagnostics?
Also, if you edit /textpattern/lib/class.thumb.php and just above line 210 (// DST erstellen) add this: var_dump($this);
If you then reproduce the problem by creating a thumbnail, you should see some more debug data at the top of the screen. Can you post that here as well?

Offline

#6 2008-03-29 18:50:19

masa
Member
From: North Wales, UK
Registered: 2005-11-25
Posts: 1,095

Re: Problems uploading images or files, creating thumbnails

Full diagnostics:

Textpattern version: 4.0.6 (r2805)
Last Update: 2008-03-11 12:01:09/2008-03-11 11:55:23
Document root: /srv/vefir/fyrirt/landslag.is/www
$path_to_site: /srv/vefir/fyrirt/landslag.is/www
Textpattern path: /srv/vefir/fyrirt/landslag.is/www/textpattern
Permanent link mode: section_title
open_basedir: /srv/:/tmp/
Temporary directory path: /tmp
Site URL: new.landslag.is
PHP version: 5.1.2
GD Image Library: bundled (2.0.28 compatible); supported formats: GIF, JPG, PNG.
Server Local Time: 2008-03-29 18:28:40
MySQL: 5.0.18-Max
Locale: en_GB.UTF-8
Server: Apache/2.2.0 (Linux/SUSE)
Apache version: Apache/2.2.0 (Linux/SUSE)
PHP Server API: apache2handler
RFC 2616 headers: 
Server OS: Linux 2.6.16.21-0.8-default

Pre-flight check: 
------------------------
Some Textpattern files have been modified: 
	/lib/classTextile.php
------------------------

.htaccess file contents: 
------------------------
#DirectoryIndex index.php index.html

Options +FollowSymLinks
Options -Indexes

<IfModule mod_rewrite.c>
	RewriteEngine On
	#RewriteBase /relative/web/path/

	RewriteCond %{REQUEST_FILENAME} -f [OR]
	RewriteCond %{REQUEST_FILENAME} -d
	RewriteRule ^(.+) - [PT,L]

	RewriteRule ^(.*) index.php

	RewriteCond %{HTTP:Authorization}  !^$
	RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
</IfModule>

#php_value register_globals 0

------------------------

Charset (default/config): latin1/utf8
character_set_client: utf8
character_set_connection: utf8
character_set_database: latin1
character_set_results: utf8
character_set_server: latin1
character_set_system: utf8
character_sets_dir: /usr/share/mysql/charsets/
17 Tables: OK

PHP extensions: libxml, xml, standard/5.1.2, SimpleXML, SPL, session, Reflection, date/5.1.2, pcre, apache2handler, bcmath, bz2, calendar, ctype, curl, dba, dbase, dom/20031129, exif/1.4 $Id: exif.c,v 1.173.2.4 2006/01/01 12:50:06 sniper Exp $, filepro, ftp, gd, gettext, gmp, iconv, imap, ldap, mbstring, mcrypt, mhash, mysql/1.0, mysqli/0.1, ncurses, odbc/1.0, openssl, pcntl, PDO, pgsql, posix, pspell, shmop, snmp, soap, sockets, SQLite, sysvmsg, sysvsem, sysvshm, tokenizer/0.1, wddx, xmlreader/0.1, xmlrpc/0.51, xsl/0.1, zlib/1.1

Apache modules: core, prefork, http_core, mod_so, mod_actions, mod_alias, mod_auth_basic, mod_authn_file, mod_authz_host, mod_authz_groupfile, mod_authz_default, mod_authz_user, mod_authn_dbm, mod_autoindex, mod_cgi, mod_dav, mod_dav_svn, mod_authz_svn, mod_dir, mod_env, mod_expires, mod_include, mod_log_config, mod_mime, mod_negotiation, mod_rewrite, mod_setenvif, mod_ssl, mod_suexec, mod_userdir, mod_suphp, mod_php5, mod_speling

/../index.php: r2774 (66519e6f500fa0e59fa27567e97d3675)
/css.php: r2772 (4807cbc15661213f2b4d0fd26c7179ff)
/include/txp_admin.php: r2729 (0c2b3cf59ff433c943bcc293a526651a)
/include/txp_article.php: r2680 (49a7155d831f843bcf3e8de306dfe7f1)
/include/txp_auth.php: r2728 (c472bfbe49a71fd35e89000c8a18de08)
/include/txp_category.php: r2243 (0ed99b6f44b5d221bdf35674240141ab)
/include/txp_css.php: r2730 (7974aa87728b39d3afaba5a3b18cf6b5)
/include/txp_diag.php: r2791 (aeb96445180b68c31821e237b6150332)
/include/txp_discuss.php: r2774 (852a8a4d4307358e161e0501124b7247)
/include/txp_file.php: r2530 (9f34fdbf98b9b649d65e2ced4c9ca763)
/include/txp_form.php: r1913 (780340d28f384113c72924843194b43e)
/include/txp_image.php: r2668 (11269b464db6cfa3affff47674533a50)
/include/txp_import.php: r1238 (86f0e64d2c9362066e6c48b9cd486e37)
/include/txp_link.php: r2463 (2379d25f83b37ec6c8d5f3edb1122ce8)
/include/txp_list.php: r2725 (1ed6c6f729eaeb7f8a582b27cd5b9e78)
/include/txp_log.php: r2796 (f249e0962a996f05041b899fea91ccae)
/include/txp_page.php: r2717 (807ff04b4a649b54b3d710c1ab0a428f)
/include/txp_plugin.php: r2774 (e9fdc47a3ed9bdd13197d929161c6a13)
/include/txp_prefs.php: r2528 (50bd3be8c22e17d5ca2855ccea081bac)
/include/txp_preview.php: r1238 (c45992b3273ac8019477e2f959d63120)
/include/txp_section.php: r2759 (9208297e0bd7b3d41bd0e6f9fc9ab120)
/include/txp_tag.php: r2774 (f371b400e8d7318e2ac48e032fe6c274)
/index.php: r2805 (ee8ab2e3c4bc9abd77aa7384ecba5268)
/lib/IXRClass.php: r765 (0120eb4713c9b6446a0eebe8b1039d1c)
/lib/admin_config.php: r1747 (b972529744cb37a7695fe00316dada41)
/lib/class.thumb.php: r2329 (c7f66a32531f32d6dfcbe5c7d26c7852)
/lib/classTextile.php: r2779 (2c5ee18a3349a5aa688fe8e829cbf335)
/lib/constants.php: r2361 (5338211ece1b2592804acdd204c9df33)
/lib/taglib.php: r2612 (727737ebd08127c632b9822bae87fee0)
/lib/txplib_admin.php: r2726 (c4f65bac2ddef62867f5bfee97ad7dfe)
/lib/txplib_db.php: r2748 (3feb369b1c34f251815cd6085a216d62)
/lib/txplib_forms.php: r2759 (a2d3de62110e582fab2a3a20224661f4)
/lib/txplib_head.php: r2783 (74ced647523a94da307af9853d7ed596)
/lib/txplib_html.php: r2696 (57985ebd2501bc303d2e97ae7538db1f)
/lib/txplib_misc.php: r2788 (7ecfaa5d4fabefbf411d01615dea9485)
/lib/txplib_update.php: r1239 (e3bd2d0c2b491d4028a656b8301a0086)
/lib/txplib_wrapper.php: r2800 (4ad38ee67f3ee8d9e7b51544a4f0f58b)
/publish.php: r2777 (0ce3da212329e7d34de07e53e109d182)
/publish/atom.php: r2774 (50aa384a2edf7cc07effee9020e0893b)
/publish/comment.php: r2776 (0e1ea64316087edcd75f394494b42100)
/publish/log.php: r1637 (f69237dc2ff39bd7a691c8ca1bc87808)
/publish/rss.php: r2793 (022caa22c756c64f2255aae6625686d8)
/publish/search.php: r1748 (ea84e04b2c688b0bb8b5a9ecf395749a)
/publish/taghandlers.php: r2774 (59dc36e6dabc619e23c43f722fe7b8f1)
/update/_to_1.0.0.php: r711 (0f49fca8fbd8e6fca0fc48b0f69f0461)
/update/_to_4.0.2.php: r711 (e77c0e0d972868f19eaee4565bd0b4c4)
/update/_to_4.0.3.php: r711 (f5506cfd0fbc3ad4bd9a9b2299468775)
/update/_to_4.0.4.php: r711 (4d867b42ee87a7f11d2bff3a8e91bed0)
/update/_to_4.0.5.php: r2464 (dbe80cd4a775d3a43a203c3c4a2d0e3f)
/update/_to_4.0.6.php: r2464 (7e5ae73eb64c24438918697089a1f321)
/update/_update.php: r2792 (6ff7b4dedb2c7735a01e76b13b3f1fb1)

additional debug data when creating thumbnail:

object(txp_thumb)#2 (18) { 
["m_ext"]=>  string(4) ".gif" 
["m_id"]=>  string(1) "1" 
["width"]=>  int(150) 
["height"]=>  string(0) "" 
["longside"]=>  NULL 
["shortside"]=>  NULL 
["extrapolate"]=>  bool(false) 
["crop"]=>  bool(false)
["sharpen"]=>  bool(true) 
["hint"]=>  string(1) "0" 
["addgreytohint"]=>  bool(true) 
["quality"]=>  int(80) 
["linkurl"]=>  NULL
["html"]=>  string(17) " alt="" title="" " 
["types"]=>  array(4) { 
  [0]=>  string(0) ""
  [1]=>  string(4) ".gif"
  [2]=>  string(4) ".jpg"
  [3]=>  string(4) ".png"
} 
["_SRC"]=>  array(8) { 
  ["file"]=>  string(46) "/srv/vefir/fyrirt/landslag.is/www/images/1.gif" 
  ["width"]=>  int(400) 
  ["height"]=>  int(1) 
  ["type"]=>  int(1) 
  ["string"]=>  string(22) "width="400" height="1"" 
  ["filename"]=>  string(5) "1.gif" 
  ["format"]=>  string(9) "landscape" 
  ["image"]=>  resource(24) of type (gd)
} 
["_DST"]=>  array(4) { 
  ["width"]=>  int(150) 
  ["height"]=>  float(0) 
  ["type"]=>  int(1) 
  ["file"]=>  string(47) "/srv/vefir/fyrirt/landslag.is/www/images/1t.gif"
} 
["link"]=>  bool(true) 
}
Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /srv/vefir/fyrirt/landslag.is/www/textpattern/lib/class.thumb.php on line 211
Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /srv/vefir/fyrirt/landslag.is/www/textpattern/lib/class.thumb.php on line 366

When I fill in a value for the height the thumb gets created, but it’s distorted.

I should perhaps also mention that I’m currently working on a subdomain new.landslag.is which the hosting provider set up so I could work without affecting the current, old site.

Thanks for your help!

Last edited by ruud (2008-03-29 19:10:08)

Offline

#7 2008-03-29 19:08:16

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Problems uploading images or files, creating thumbnails

The relevant part is:

["_SRC"]=>  array(8) { 
  ["width"]=>  int(400) 
  ["height"]=>  int(1) 
} 
["_DST"]=>  array(4) { 
  ["width"]=>  int(150) 
  ["height"]=>  float(0)
}

The problem is that the original image is 400px wide and 1px high. You specify that the thumbnail should be 150px wide, but in an attempt to maintain aspect ratio, the height becomes 0px, which is an invalid image height, because 0px = no image.

Here’s a patch:

--- textpattern/lib/class.thumb.php	(revision 2851)
+++ textpattern/lib/class.thumb.php	(working copy)
@@ -207,6 +207,10 @@
 	    }
 	}

+	// ensure non-zero height/width
+	if (!$this->_DST['height']) $this->_DST['height'] = 1;
+	if (!$this->_DST['width'])  $this->_DST['width']  = 1;
+
 	// DST erstellen
 	$this->_DST['image'] = imagecreatetruecolor($this->_DST['width'], $this->_DST['height']);
 	imagecopyresampled($this->_DST['image'], $this->_SRC['image'], 0, 0, $off_w, $off_h, $this->_DST['width'], $this->_DST['height'], $this->_SRC['width'], $this->_SRC['height']);

Last edited by ruud (2008-03-29 19:17:08)

Offline

#8 2008-03-29 19:13:57

masa
Member
From: North Wales, UK
Registered: 2005-11-25
Posts: 1,095

Re: Problems uploading images or files, creating thumbnails

OK, that makes perfect sense. Since it’s Txp’s default divider.gif it doesn’t bother me.

However I still need to figure out, why I can’t upload any images or files at all.

Any ideas?

Offline

#9 2008-03-29 20:22:29

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Problems uploading images or files, creating thumbnails

Okay, that’s a different problem.
Try adding var_dump($_FILES); on the second line of /textpattern/include/txp_image.php and then try uploading an image and post the debug info that shows at the top.

Offline

#10 2008-03-29 20:34:48

masa
Member
From: North Wales, UK
Registered: 2005-11-25
Posts: 1,095

Re: Problems uploading images or files, creating thumbnails

That produces:

array(1) {
  ["thefile"]=>
  array(5) {
    ["name"]=>
    string(11) "thrainn.jpg"
    ["type"]=>
    string(10) "image/jpeg"
    ["tmp_name"]=>
    string(14) "/tmp/phpCFHFUN"
    ["error"]=>
    int(0)
    ["size"]=>
    int(28274)
  }
}

Offline

#11 2008-03-29 20:59:40

masa
Member
From: North Wales, UK
Registered: 2005-11-25
Posts: 1,095

Re: Problems uploading images or files, creating thumbnails

ruud wrote:

Here’s a patch:

Ruud, thanks for the patch.

Just to be sure I’m doing this properly, I need to paste only the four lines prefixed with + into the existing class.thumb.php omitting the + ?

Last edited by masa (2008-03-29 21:14:02)

Offline

#12 2008-03-29 21:15:44

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Problems uploading images or files, creating thumbnails

Okay, put this at the top of that txp_image.php file instead:

var_dump($_FILES);
if ($_FILES)
{
  $f = $_FILES['thefile']['name'];
  echo ' is_uploaded_file: ';
  var_dump(is_uploaded_file($f));
  echo ' tempnam: ';
  $newfile = tempnam($GLOBALS['tempdir'], 'txp_');
  var_dump($newfile);
  echo ' move uploaded file: ';
  var_dump(move_uploaded_file($f, $newfile));
}

Last edited by ruud (2008-03-29 22:34:21)

Offline

Board footer

Powered by FluxBB