Jump to content

php mysql video uploading problem


varun7952

Recommended Posts

hi i m new to php

there is two basic script i m testing on my localhost but it gives me error

 

  "( ! ) Notice: Undefined index: video in C:\wamp\www\Boysjoys\video\upload.php on line 4"

  "( ! ) Notice: Undefined index: video in C:\wamp\www\Boysjoys\video\upload.php on line 16"

  "( ! ) Notice: Undefined index: video in C:\wamp\www\Boysjoys\video\upload.php on line 27"

 

i cant find where is the real problem is

 

##########FORM###########

<form name="upload" action="upload.php" method="POST" enctype="multipart/form-data">

<input type="file" name="video">

<input type="submit" value="UPLOAD">

</form>

#########FORM############

#########PHP#############

<?php

// This is the directory where images will be saved

$path="uploaded/";

$path=$path.basename($_FILES["video"]["name"]);

 

//This gets all the other information from the form

 

 

$video=$_FILES["video"]["name"];

 

//connect to  database

$con=mysql_connect("localhost","root","") or die (mysql_error());

//SELECTING THE DATABASE

mysql_select_db("admin_bj",$con) or die(mysql_error());

//write information to the database

 

mysql_query("INSERT INTO 'video'(video) VALUES('$video')");

 

//write file to server

if(move_uploaded_file($_FILES["video"]["tmp_name"],$path))

{

// execute if all is ok

echo "the file " . basename( $_FILES['uploadedfile']['name']). "has been uploaded and your information has been added to the server";

}

else {

//GIVES AND ERROR IF ITS NOT OK

echo "Sorry,there was a problem in uploading.";

}

?>

 

#########PHP#############

 

Link to comment
https://forums.phpfreaks.com/topic/257255-php-mysql-video-uploading-problem/
Share on other sites

Add this to your script, immediately after the opening <?php tag so you can see what the form is actually sending.

 

echo '-----POST-----<br><pre>';
print_r($_POST);
echo '</pre>-----FILES-----<br><pre>';
print_r($_FILES);
echo </pre>';

Add this to your script, immediately after the opening <?php tag so you can see what the form is actually sending.

 

echo '-----POST-----<br><pre>';
print_r($_POST);
echo '</pre>-----FILES-----<br><pre>';
print_r($_FILES);
echo </pre>';

ok i did ths also ths will mk array bt this return a blank array nothing else bt with same error :(

Does changing these to single quotes make a difference?

$path=$path.basename($_FILES['video']['name']);

//This gets all the other information from the form


$video=$_FILES['video']['name']; 

 

I can't get code to fail.  Seems to be working fine.

i already tried this

can ne1 try ths at thr own localhost

One more try.

<?php
// This is the directory where images will be saved
if (isset($_FILES['video'])){
$path="uploaded/";
$path=$path.basename($_FILES["video"]["name"]);

//This gets all the other information from the form


$video=$_FILES["video"]["name"];

//connect to  database
$con=mysql_connect("localhost","root","") or die (mysql_error());
//SELECTING THE DATABASE
mysql_select_db("admin_bj",$con) or die(mysql_error());
//write information to the database

mysql_query("INSERT INTO `video`(video) VALUES('$video')");

//write file to server
if(move_uploaded_file($_FILES["video"]["tmp_name"], $path))
{
   // execute if all is ok
   echo "the file " . basename( $_FILES['video']['name']). "has been uploaded and your information has been added to the server";
   }
   else {
   //GIVES AND ERROR IF ITS NOT OK
echo "Sorry,there was a problem in uploading.";
   }
}//if (isset($_FILES['video'])){
?>

One more try.

<?php
// This is the directory where images will be saved
if (isset($_FILES['video'])){
$path="uploaded/";
$path=$path.basename($_FILES["video"]["name"]);

//This gets all the other information from the form


$video=$_FILES["video"]["name"];

//connect to  database
$con=mysql_connect("localhost","root","") or die (mysql_error());
//SELECTING THE DATABASE
mysql_select_db("admin_bj",$con) or die(mysql_error());
//write information to the database

mysql_query("INSERT INTO `video`(video) VALUES('$video')");

//write file to server
if(move_uploaded_file($_FILES["video"]["tmp_name"], $path))
{
   // execute if all is ok
   echo "the file " . basename( $_FILES['video']['name']). "has been uploaded and your information has been added to the server";
   }
   else {
   //GIVES AND ERROR IF ITS NOT OK
echo "Sorry,there was a problem in uploading.";
   }
}//if (isset($_FILES['video'])){
?>

 

i tried isset function before but this time itsnot showing any error but its return a blank page without uploading anyway thanks for ur effort

Add this to your script, immediately after the opening <?php tag so you can see what the form is actually sending.

 

echo '-----POST-----<br><pre>';
print_r($_POST);
echo '</pre>-----FILES-----<br><pre>';
print_r($_FILES);
echo </pre>';

 

Where did you put this code? Post the file you edited, with this code added to it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.