Error analyzing $_FILES in module.tag.apetag.php?...

Locked
Hartleigh
User
Posts: 8
Joined: Thu Apr 05, 2007 4:49 am
Location: Brisbane, Australia

Error analyzing $_FILES in module.tag.apetag.php?...

Post by Hartleigh » Wed Jun 13, 2007 1:40 am

Hi There,

I am trying to analyze a temporary uploaded file. File is uploaded via POST and kept in the default php upload directory. realpath = "C:\Program Files\PHP\upload\php167C.tmp" as an example. When I upload the file and try to get getid3 to analyze it I receive the following error...

Fatal Error: (8): Undefined index: ape in <B>C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\_dev\mraintranet\classes\getid3\module.tag.apetag.php</B> on line <B>68</B>

Using: PHP 5.2.1, Apache 2.2.3, GetID3() v2.0.0b4

Here is the code I am currently using...

Code: Select all

require_once('classes/getid3/getid3.php');
foreach ($_FILES['trackdata']['name'] as $k => $v) {
	if ($_FILES['trackdata']['tmp_name'][$k] != NULL) {
		if (substr($_FILES['trackdata']['type'][$k],0,5) == "audio") {
			if (!$file = fopen($_FILES['trackdata']['tmp_name'][$k],"rb")) {
				Step1("There was an error while opening '".$v."'.");
			}
			$real = realpath($_FILES['trackdata']['tmp_name'][$k]);
			//Step3($real); <- output example: C:\Program Files\PHP\upload\php167C.tmp
			$getid3 = new getID3;
			$getid3->encoding = 'UTF-8';
			try {
				$getid3->Analyze($real);
			} catch (Exception $e) {
				Step3($e->message);
			}
			Step3("OK");
		}
	}
}
If anyone has any ideas why I receive the above error and can help, the assistance would be greatly appreciated. On a similar note, before uploading the file and trying to build this script I placed the test.aiff file I am using into the getid3 demo directory and successfully analyzed it using the demo scripts. I hope there is enough information there ;)

Allan Hansen
getID3() v2 developer
Posts: 445
Joined: Sun May 04, 2003 2:22 pm
Location: Holmegaard, Denmark

Post by Allan Hansen » Wed Jun 13, 2007 7:13 am

A very strange error indeed.

Line 68 in the apetag module looks like this:

if (!@$getid3->info['ape']['tag_offset_end']) {

Why would this give a Fatal Error?

Rewriting it to

if (!isset($getid3->info['ape']['tag_offset_end'])) {

might help.

Anyway, it may be a bug in PHP. Please try upgrading it to 5.2.3.

Please report back if any of those two things fixes your problem.

Hartleigh
User
Posts: 8
Joined: Thu Apr 05, 2007 4:49 am
Location: Brisbane, Australia

Post by Hartleigh » Wed Jun 13, 2007 9:17 am

Hi Allan,

Thanks for the reply.

I tried your first suggestion by modifying line 68. It fixed that section but then had a very similar problem in another area:

Fatal Error: (8): Undefined index: fail_id3 in <B>C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\_dev\mraintranet\classes\getid3\getid3.php</B> on line <B>258</B>

I then upgraded to PHP 5.2.3 as you recommended also. This did not fix the problem. So I made similar changes to line 258 of getid3.php, and then another script/line, and again, and again... everywhere that has the suppress error operator @ seems to spit out the same problem, different variable/index. I can't work out why this would not happen however with the demo scripts that come with the package, which are successful on the same server!?

I can go through every line painstakingly to make modifications so it works for my intention... but there has to be a reason/easier fix. Do you have any further ideas?

Cheers.

Hartleigh
User
Posts: 8
Joined: Thu Apr 05, 2007 4:49 am
Location: Brisbane, Australia

Post by Hartleigh » Thu Jun 14, 2007 3:17 am

Finally got it working properly.

Instead of using this:

Code: Select all

try {
	$getid3->Analyze($real);
} catch (Exception $e) {
	Step3($e->message);
}
i am now using this:

Code: Select all

try {
	@$getid3->Analyze($real);
} catch (Exception $e) {
	Step3($e->message);
}
Thanks for the assistance Allan. ;)

Hartleigh
User
Posts: 8
Joined: Thu Apr 05, 2007 4:49 am
Location: Brisbane, Australia

Post by Hartleigh » Thu Jun 14, 2007 4:25 am

Delving further into this problem... it seems custom error handling with E_NOTICE is screwing with it :|

Locked