Jump to content

Why do i get error, file uploading ?


jd2007

Recommended Posts

<?php
class FlashUploader
{
  private $host;
  private $username;
  private $password;
  private $db;
  private $table;
  private $title;
  private $brief;
  private $main;
  private $checkboxes;
  private $flash;
  private $flashtype;
  private $flashsize;
  private $flashtmp;
  //private $thumb;
  private $author;
  private $submitted;
  private $score;
  private $size;

  function connectdb($l, $u, $p, $d)
{
      $this->host=$l;
      $this->username=$u;
  $this->password=$p;
  $this->db=$d;
  mysql_connect($this->host, $this->username, $this->password);
  mysql_select_db($this->db);
}

  function getandsendDetails($ftitle, $fbrief, $fmain, $fcbx, $aut, $subm, $sc)
{
  $this->checkboxes=explode("/", $fcbx);
      $this->que="insert into videos (title, brief, main, author, submitted, size) values ($this->title, $this->brief, $this->main, $this->author, $this->submitted, $this->size)";
  $this->res=mysql_query($this->que);
}

function checkFiles($file, $filetype, $filesize, $filetmp)
{ 
	echo $this->flash=$file;
              echo $this->flashtype=$filetype;
             $this->flashsize=$filesize;
	echo $this->flashtmp=$filetmp;
	/*
	$this->thumb=$thumbnail;
	$this->thumbtype=$thumbnailtype;
        $this->thumbsize=$thumbnailsize;
	$this->thumbtmp=$thumbnailtmp;*/

      if (is_uploaded_file($this->flash))
	{
           if (filetype($this->flashtype)=="application/x-shockwave-flash")
		{
              if (filesize($this->flashsize)>=3000000)
		 {
              echo "Flash is good !";
		 }
		 else
		 {
              echo "Flash too large.";
		 }
		}
		else
		{
              echo "Flash not valid type.";
		}
	}
      else
	{
          echo "Flash doesn't exist.";
	}
}

function moveFiles()
{
      move_uploaded_file($this->flashtmp, "a/");
}
}

$flashupload=new FlashUploader;
$flashupload->connectdb("localhost", "root", "*****", "videoportal");
$x=$flashupload->checkFiles($_FILES["filef"]["name"], $_FILES["filef"]["type"], $_FILES["filef"]["size"], $_FILES["filef"]["tmp_name"]);
if ($x=="Flash is good !")
{
$y=$flashupload->moveFiles();
if (!$y)
{
  echo "File could not be uploaded";
}
else
{
$flashupload->getandsendDetails($_POST["textfield4"], $_POST["textfield5"], $_POST["textfield52"], $_GET["arr"], "jd2007", "2", "0");
}
}
else
{
echo $x;
print_r(error_get_last());
}
?>

 

i get this output:

 

Luciano Pavarotti and Elton John - Live Like Horses.mp3Flash doesn't exist.Array ( [type] => 8 [message] => Undefined variable: flashtmp [file] => C:\AppServ\www\a\flashportal\flash_upload.php [line] => 46 )

Link to comment
Share on other sites

Is there anything wrong in my code below- the file is not uploading?

 

function moveFiles()
{
  move_uploaded_file($this->flashtemp,"C:\AppServ\www\a\flashportal\flash");
}

 

$this->flashtemp is $_FILES["filef"]["tmp_name"].

i want to upload in folder 'flash'.

Link to comment
Share on other sites

pls help...

 

here is my code updated:

 

<?php
class FlashUploader
{
  private $a=0;
  private $host;
  private $username;
  private $password;
  private $db;
  private $table;
  private $title;
  private $brief;
  private $mainx;
  private $checkboxes;
  private $flash;
  private $flashtype;
  private $flashsize;
  private $flashtemp;
  private $author;
  private $submitted;
  private $score;
  private $size;
  private $que;
  private $res;

  function connectdb($l, $u, $p, $d)
{
      $this->host=$l;
      $this->username=$u;
  $this->password=$p;
  $this->db=$d;
  mysql_connect($this->host, $this->username, $this->password);
  mysql_select_db($this->db);
}

  function getandsendDetails($ftitle, $fbrief, $fmain, $fcbx, $aut, $subm, $sc)
{
  $this->title=$ftitle;
  $this->brief=$fbrief;
      $this->mainx=$fmain;
      $this->author=$aut;
  $this->submitted=$subm;
  $this->score=$sc;
  $this->checkboxes=explode("/", $fcbx);
      echo $this->que="insert into videos (title, brief, main, author, submitted, size, score) values ('$this->title', '$this->brief', '$this->mainx', '$this->author', '$this->submitted', '$this->flashsize', '$this->score')";
  $this->res=mysql_query($this->que);
}

function checkFiles($file, $filetype, $filesize, $filetmp)
{ 
	$this->flash=$file;
         $this->flashtype=$filetype;
        $this->flashsize=$filesize;
         echo $this->flashtemp=$filetmp;

     if (is_uploaded_file($this->flashtemp))
	{
           if ($this->flashtype=="application/x-shockwave-flash")
		{
              if ($this->flashsize<3000000)
		 {
              echo "1";
		 }
		 else
		 {
              echo "Flash too large.";
		 }
		}
		else
		{
              echo "Flash not valid type.";
		}
	}
      else
	{
          echo "Flash doesn't exist.";
	}
}

function moveFiles()
{
      move_uploaded_file($this->flash,"C:\AppServ\www\a\flashportal\flash");
}
}

$flashupload=new FlashUploader;
$flashupload->connectdb("localhost", "root", "*****", "videoportal");
$flashupload->checkFiles($_FILES["filef"]["name"], $_FILES["filef"]["type"], $_FILES["filef"]["size"], $_FILES["filef"]["tmp_name"]);
$flashupload->moveFiles();
$flashupload->getandsendDetails($_POST["textfield4t"], $_POST["textfield5t"], $_POST["textfield52t"], $_GET["arr"], "jd2007", "12-09-2007 12:21:30", "2");

?>

Link to comment
Share on other sites

Try:

 

move_uploaded_file($this->flash,"C:\AppServ\www\a\flashportal\flash\".basename($_FILES['filef']['name']));

 

By the way, your checkFiles method is verifying the mime type with $_FILES["filef"]["type"] which is not to be trusted since that is determined by the browser which only checks the file extension and not the file header/content. You may want to check out the PECL fileinfo extension.

Link to comment
Share on other sites

  • 2 months later...
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.