Location: PHPKode > projects > PodAdmin - Web-based podcast management > podadmin-0.5.1/act_upload.php
<?php
// processes the dsp_upload.php form

$errors = array();

if (! $_FILES['userfile']['size']) {
	array_push($errors,"No file selected or file is empty.");
	}
else {
	$filename = str_replace(" ","",$_FILES['userfile']['name']);
	$uploadfile    = $vsf->config->misc->datadir . "/"     . $filename;
	$tmpuploadfile = $vsf->config->misc->datadir . "/tmp_" . $filename;
	
	if (file_exists($uploadfile)) {
		array_push($errors,"A file with that name already exists ($filename)");
		}
	// else attempt to move the file into our temporary area
	elseif (! @move_uploaded_file($_FILES['userfile']['tmp_name'], $tmpuploadfile)) {
		array_push($errors,"Could not copy file to datadir.  Perhaps directory is not writable? ("
		. $vsf->config->misc->datadir . ")");
		}
	else {
		// else the move succeeded.  Now need to change permissions to 666, otherwise
		// the file will probably only be readable by the webserver, which makes things difficult
		// if the webmaster ever wants to do anything with the file.
		chmod($tmpuploadfile,0666);
		} 
	} // close else after if not $_FILES['userfile']['size']

	
// if any errors, display the form.
if ($errors) {
	include('dsp_upload.php');
	}
else {
	// else, attempt to get any useful data from the mp3 file, then show the file detail form

	// load the ID3 tag reading library
	require_once('getid3/getid3.php');
	$getID3 = new getID3;
	
	// Analyze file and store returned data in $ThisFileInfo
	$ThisFileInfo = $getID3->analyze($tmpuploadfile);

	$_POST['userfile'] = $filename;	
	$_POST['title'] = $ThisFileInfo['tags']['id3v2']['title'][0];
	$_POST['description'] = $ThisFileInfo['tags']['id3v2']['comment'][0];
	$_POST['size'] = $ThisFileInfo['filesize'];
	$_POST['duration'] = $ThisFileInfo['playtime_string'];
	$_POST['pubdate'] = date("m/d/y");

    include('dsp_upload2.php');
	}


?>
Return current item: PodAdmin - Web-based podcast management