Jump to content

it doesnt store the value


etsted

Recommended Posts

// this makes every file name unique	$fileName = $_FILES['Filedata']['name'];	$kaboom = explode(".",$fileName);	$ext = "";	$ext = end($kaboom);	$ext = strtolower($ext);        $fileName = date("YmdjzHhisu") . rand(10000000,99999999) . ".$ext";				// defines what the ext can be	$imageTypes = array('jpg','jpeg','gif','png');	$videoTypes = array('mp4','webm','ogg','wmv');	$audioTypes = array('mp3','ogg','wav');			$title = $_POST['title'];	$description = $_POST['description'];	$username = $_POST['username'];		// include DB connection	include_once ("../connect.php");			// use the pathinfo to match the ext of the uploaded file	$fileParts = pathinfo($_FILES['Filedata']['name']);	$fileParts = $fileParts['extension'];	$fileParts = strtolower($fileParts);		if (in_array($fileParts,$imageTypes)) { // this is for images	// insert into DB		$sql = "INSERT INTO images VALUES('', '$title', '$description', '$username', '$fileName'  , NOW(), '')";		$query = mysqli_query($con, $sql);		move_uploaded_file($tempFile, "../u_image/" . $fileName);		echo '1';	} else if(in_array($fileParts, $videoTypes)){ // this is for videos	// insert into DB		$sql = "INSERT INTO videos VALUES('', '$title', '$description', '$username', '$fileName'  , NOW(), '')";		$query = mysqli_query($con, $sql);		move_uploaded_file($tempFile, "../videos/" . $fileName);		echo '1';	} else if(in_array($fileParts,$audioTypes)){ // this is for audios	// insert into DB		$sql = "INSERT INTO mp3 VALUES('', '$title', '$description', '$username', '$fileName'  , NOW(), '')";		$query = mysqli_query($con, $sql);		move_uploaded_file($tempFile, "../audio/" . $fileName);		echo '1';	} else {		echo "Invalid file.";	}

this script is supposed to store images , videos and mp3. It only store images not mp3 or video file.

I have created the map for mp3 videos and images.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...