upload problem with getid3

The place for "I can't figure out how to..." questions.
Post Reply
ARARGON
User
Posts: 3
Joined: Fri Dec 15, 2006 9:49 pm

upload problem with getid3

Post by ARARGON » Fri Dec 15, 2006 10:14 pm

Hi folks,
I#m from germany, so don't laugh about my english! ;-)
I got a problem with my upload-script.
I wanna check a file with getid3() like that ->
if mime-type from getid3 match with "audio/mpeg", the file is okay and can be uploaded!

maybe the code says more than my endlish! ;-)

Code: Select all

<?php
error_reporting(E_ALL);
## Einstellungen:
$max_size = "15000000"; //In Bytes
$ordner = "htdocs/test/upload/"; //In den Ordner wird das Bild geladen

$save = true; //false wenn der Bildpfad nicht gespeichert werden soll
$save_name = "upload_info"; /*der MySQL-Tabelle, in dem die URL zum Bild gespeichert werden soll.*/

## Zur Datenbank connecten
include("conection_local_.inc.php");

## Bild-Daten werden aus $_FILES "geholt"
$audio_typ = $_FILES['audio']['type'];
$audio_groesse = $_FILES['audio']['size'];
$audio = $_FILES['audio']['tmp_name'];
$audio_name = $_FILES['audio']['name'];

$upper = $_POST['upper'];
$info = $_POST['about'];
$pfad = $ordner.$bild_name;
if(($audio_groesse <= $max_size)) {

 // include getID3() library (can be in a different directory if full path is specified)
require_once('getid3/getid3/getid3.php');

// Initialize getID3 engine
$getID3 = new getID3;

// Analyze file and store returned data in $ThisFileInfo
$ThisFileInfo = $getID3->analyze($audio);

getid3_lib::CopyTagsToComments($ThisFileInfo);

if (@$ThisFileInfo['mime_type'] == "audio/mpeg" ) {

   $dest = $ordner;
   if(move_uploaded_file($audio, $dest . $_FILES['audio']['name'])) {
              	mysql_query("INSERT INTO ".$save_name." SET upper = '".$upper."', bild = '".$audio_name."',info = '".$info."' ");
              	echo "UPLOAD COMPLETED<br>";


   }
}
}
else {
   if($audio_groesse > $max_size) {
    echo "FILE is to big";
   }
   else {
    echo "FILE has to be an AUDIO-FILE!";
    echo "Typ: ".$audio_typ;
   }

}
?>
the code doesn't give me any warnings or notices.
the fact of the matter is this, I wanna check a file before it is on the server!
I kwo that my $audio is the temp_dir_file therefor there is maybe no information what getid3 need, but how I can find out the local path of the upload-file from the client!?
is that possible??I hope so!
I hope you can help me!
you did a great work with that script!

THX, ara

James Heinrich
getID3() v1 developer
Posts: 1476
Joined: Fri May 04, 2001 4:00 pm
Are you a spambot?: no
Location: Northern Ontario, Canada
Contact:

Post by James Heinrich » Fri Dec 15, 2006 11:30 pm

You cannot look through a visitor's computer and examine their files. You have to wait until they upload the file to you before you can look at it.

ARARGON
User
Posts: 3
Joined: Fri Dec 15, 2006 9:49 pm

Post by ARARGON » Fri Dec 15, 2006 11:58 pm

first of all thanks for the answer, but
I found the faillure, it wasn't my code.
it was my php.ini there I had to edit some option.
-> memory_limit
-> post_max_size
-> upload_max_filesize

these are very important options to upload a file!

so I tried to start the code with many files, different size, type and so on.
and 95% of my trials were successful, but I still don't know why 95% and not 100%!

could you start this code on your pc, please!
maybe you find out where I lose the 5%!

THX

ARARGON
User
Posts: 3
Joined: Fri Dec 15, 2006 9:49 pm

Post by ARARGON » Thu Dec 21, 2006 8:19 pm

thanks for your response! ;-)

Post Reply