Jump to content

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.

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.