Jump to content

[SOLVED] Upload Script


bruckerrlb

Recommended Posts

Hello!

 

I am trying to modify a script here, an old script, what happens is, there is a flash uploader, and this flash uploader uploads a video, when the video is complete, it runs a script. I am trying to modify this script, so that when it adds the video, it not only adds the video into the specific folder, but also adds this record in the database (to be able to call the video path back on the front end). I cannot seem to figure out what I am doing wrong though! Below is my code with comments to try and explain my theory


<?php



$uploaddir = dirname($_SERVER['SCRIPT_FILENAME'])."/UploadedFiles/";

$target_encoding = "ISO-8859-1";
echo '<pre>';
if(count($_FILES) > 0)
{
$arrfile = pos($_FILES);
$uploadfile = $uploaddir . iconv("UTF-8", $target_encoding,basename($arrfile['name']));

//the below part is to test to make sure that the file is a .swf and to make sure it was uploaded

if ((move_uploaded_file($arrfile['tmp_name'], $uploadfile)) && ($_FILES["file"]["type"] == "application/x-shockwave-flash"))

{
//get my database connection
	include('/../../../../includes/db_connect.php');

	//insert it into the database	
	$query = "INSERT INTO video
		(id, path, page)

			VALUES (0, '$uploadfile' ,  'livevideo')";

	if (@mysql_query ($query)) {
	print 'Successfully Added!';
	}

}


	mysql_close();
	}


}

?>






 

Any help is much appreciated!

 

Link to comment
Share on other sites

if the file was uploading then not likely,

 

next thing I would try is breaking up the query a little

 

		$query = "INSERT INTO video
		(path, page) VALUES ('".$uploadfile."' ,  'livevideo')";

\

 

if that doesn't work I'm not sure where to go with it without knowing more about the server and DB

Link to comment
Share on other sites

Hello all, thanks for your help, I think the problem was my file db_connect. I finally just decided to put the connection in the actual file without any includes. The reason for this is, it's on a backend, the uploader cannot be accessed unless the user is signed in and then they can use it. So thanks for everything!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.