Jump to content

can't uploading multiple video file with one form submission


ash007

Recommended Posts

Hi,

  When I am trying to upload the multiple video file with one form submission it’s display the messge failed to upload the video file…

But the same code is working for image uploading…I created the .htaccess file and

changed the max_file_size is 35M.

 

Can anybody please help me to find out the problem.

 

For your kind ref here I m incluing the code

 

fliplistproperty2.php

<div id="Layer1">

  <form action="listpropertysuccess2.php" method="post" enctype="multipart/form-data" name="form1" id="form1">

    <div align="center">

      <table width="613" height="712" border="0" cellspacing="0">

          <tr>

            <td width="149" class="headingstyle style1">List Property </td>

            <td width="216"> </td>

            <td width="88"> </td>

            <td width="152"> </td>

          </tr>

          <tr>

            <td class="headingstyle style1"> </td>

            <td> </td>

            <td> </td>

            <td> </td>

          </tr>

          <tr>

            <td> <div align="center"><strong>Contact Information </strong></div></td>

            <td> </td>

            <td> </td>

            <td> </td>

          </tr>

          <tr>

            <td height="27"><div align="center">*Name:</div></td>

            <td><input type="text" name="name" /></td>

            <td><p>

<input name="ntype" type="radio" value="Owner" />             

Owner

            </p>

              <p>

                <input name="ntype" type="radio" value="Realtor" />

              Realtor</p></td>

            <td> </td>

          </tr>

          <tr>

            <td height="45"><div align="center">Address:</div></td>

            <td><textarea name="address" cols="16"></textarea></td>

            <td>*Email:</td>

            <td><input type="text" name="email" /></td>

          </tr>

          <tr>

            <td height="30"><div align="center">City:</div></td>

            <td><input type="text" name="city" /></td>

            <td>*Phone:</td>

            <td><input type="text" name="phone" /></td>

          </tr>

          <tr>

            <td height="36"><div align="center">State:</div></td>

            <td><input type="text" name="state" /></td>

            <td>Mobile:</td>

            <td><input type="text" name="mobile" /></td>

          </tr>

          <tr>

            <td height="31"><div align="center">Zip:</div></td>

            <td><input type="text" name="zip" /></td>

            <td> </td>

            <td> </td>

          </tr>

          <tr>

            <td height="26" colspan="2"><div align="center"><strong>Property Information  </strong></div></td>

            <td> </td>

            <td> </td>

          </tr>

          <tr>

            <td height="44">Address</td>

            <td><textarea name="paddress" cols="16"></textarea></td>

            <td>State</td>

            <td><input type="text" name="pcity" /></td>

          </tr>

          <tr>

            <td height="30">City</td>

            <td><input type="text" name="pstate" /></td>

            <td>CMY</td>

            <td><input type="text" name="cmy" /></td>

          </tr>

          <tr>

            <td height="34">Zip</td>

            <td><input type="text" name="pzip" /></td>

            <td>Property Type </td>

            <td><select name="ptype">

              <option>--select--</option>

              <option>1</option>

              <option>2</option>

              <option>3</option>

              <option>Four</option>

                                    </select></td>

          </tr>

          <tr>

            <td height="32">No of Beds </td>

            <td><input type="text" name="numofbeds" /></td>

            <td>No of Baths </td>

            <td><input type="text" name="numofbaths" /></td>

          </tr>

          <tr>

            <td> </td>

            <td> </td>

            <td> </td>

            <td> </td>

          </tr>

          <tr>

            <td><input type=hidden name=MAX_FILE_SIZE value=150000>

            <input type=hidden name=completed value=1></td>

            <td> </td>

            <td> </td>

            <td> </td>

          </tr>

          <tr>

            <td> </td>

            <td> </td>

            <td> </td>

            <td> </td>

          </tr>

          <tr>

            <td height="24" colspan="2"><div align="center"><strong>Upload Picture/Video</strong></div></td>

            <td> </td>

            <td> </td>

          </tr>

          <tr>

            <td height="34"> </td>

            <td height="34"><input type="file" name="uploaded_file[]" /></td>

            <td> </td>

            <td> </td>

          </tr>

          <tr>

            <td height="31"> </td>

            <td height="31"><input type="file" name="uploaded_file[]" /></td>

            <td> </td>

            <td> </td>

          </tr>

          <tr>

            <td height="33"> </td>

            <td height="33"><input type="file" name="uploaded_file[]" /></td>

            <td> </td>

            <td> </td>

          </tr>

          <tr>

            <td height="33">Short Description </td>

            <td height="33"><textarea name="shortdescription" cols="25" rows="3" id="shortdescription"></textarea></td>

            <td> </td>

            <td> </td>

          </tr>

          <tr>

            <td height="31" colspan="2"></td>

            <td> </td>

            <td> </td>

          </tr>

          <tr>

            <td colspan="4"><div align="center">

              <input name="sendForm" type="submit" id="sendForm" value="Upload"/>

            </div></td>

            </tr>

          </table>

    </div>

  </form></div>

 

listpropertysuccess2.php

<div id="Layer1">

<form id="form1" name="form1" method="post" action="">

    <div align="center"></div>

<div align="center">

  <p>

  <?php

mysql_connect("colonizer1","user1","123");

mysql_select_db('fliptexashomes');

 

 

if (!empty($_REQUEST['sendForm']))

{

 

$file_name = $_FILES['uploaded_file']['name'][0];

  $file_name2 = $_FILES['uploaded_file']['name'][1];

$file_name3 = $_FILES['uploaded_file']['name'][2];

 

 

    $name = $_FILES['uploaded_file']['name'][0];

$name2 = $_FILES['uploaded_file']['name'][1];

$name3 = $_FILES['uploaded_file']['name'][2];

    // Assign the tmp_name to a variable

    $tmp_name = $_FILES['uploaded_file']['tmp_name'][0];

$tmp_name2 = $_FILES['uploaded_file']['tmp_name'][1];

$tmp_name3 = $_FILES['uploaded_file']['tmp_name'][2];

    // Assign the error to a variable

    $error = $_FILES['uploaded_file']['error'][0];

$error2 = $_FILES['uploaded_file']['error'][1];

$error3 = $_FILES['uploaded_file']['error'][2];

    // Assign the size to a variable

    $size = $_FILES['uploaded_file']['size'][0];

$size2 = $_FILES['uploaded_file']['size'][1];

$size3 = $_FILES['uploaded_file']['size'][2];

    // No trailing slash, folder where you want it uploaded too

    $uploadFilesTo = 'videos';

    // Create safe filename

    $name = ereg_replace('[^A-Za-z0-9.]', '-', $name);

$name2 = ereg_replace('[^A-Za-z0-9.]', '-', $name2);

$name3 = ereg_replace('[^A-Za-z0-9.]', '-', $name3);

 

 

    // Disallowed file extensions

    $naughtyFileExtension = array("php","txt", "pdf","java", "doc", "xsl", ".net");

    // Returns an array that includes the extension

    $fileInfo = pathinfo($name);

$fileInfo2 = pathinfo($name2);

$fileInfo3 = pathinfo($name3);

    // Check extension

    if (!in_array($fileInfo['extension'], $naughtyFileExtension))

    {

      // Get filename

      $name = getNonExistingFilename($uploadFilesTo, $name);

      // Upload the file

      if (move_uploaded_file($tmp_name, $uploadFilesTo.'/'.$name))

      {

          // Show success message

echo " this:<EMBED SRC='/".$uploadFilesTo.'/'.$name." WIDTH=313 HEIGHT=252>";

/*           echo '<center><p>File uploaded to /'.$uploadFilesTo.'/'.$name.'</p></center><meta http-equiv="Refresh" content="0; URL=http://www.yoursite.com/folder thats its uploaded too">';*/

      }

 

 

      else

      {

          // Show failure message

          echo '<center><p>File failed to upload to /'.$name.'</p></center>';

      }

    }

//-----------------

if (!in_array($fileInfo2['extension'], $naughtyFileExtension))

    {

      // Get filename

      $name2 = getNonExistingFilename($uploadFilesTo, $name2);

      // Upload the file

      if (move_uploaded_file($tmp_name2, $uploadFilesTo.'/'.$name2))

      {

          // Show success message

echo " this:<EMBED SRC='/".$uploadFilesTo.'/'.$name2." WIDTH=313 HEIGHT=252>";

/*           echo '<center><p>File uploaded to /'.$uploadFilesTo.'/'.$name.'</p></center><meta http-equiv="Refresh" content="0; URL=http://www.yoursite.com/folder thats its uploaded too">';*/

      }

 

      else

      {

          // Show failure message

          echo '<center><p>File failed to upload to /'.$name2.'</p></center>';

      }

    }

//------------------

if (!in_array($fileInfo3['extension'], $naughtyFileExtension))

    {

      // Get filename

      $name3 = getNonExistingFilename($uploadFilesTo, $name3);

      // Upload the file

      if (move_uploaded_file($tmp_name3, $uploadFilesTo.'/'.$name3))

      {

          // Show success message

echo " this:<EMBED SRC='/".$uploadFilesTo.'/'.$name3." WIDTH=313 HEIGHT=252>";

/*           echo '<center><p>File uploaded to /'.$uploadFilesTo.'/'.$name.'</p></center><meta http-equiv="Refresh" content="0; URL=http://www.yoursite.com/folder thats its uploaded too">';*/

      }

 

      else

      {

          // Show failure message

          echo '<center><p>File failed to upload to /'.$name3.'</p></center>';

      }

    }

//-------------------

    else

    {

        // Bad File type

        echo '<center><p>The file uses an extension we don\'t allow.</p></center>';

    }

$query="insert into listproperty(name,ntype,address,email,city,phone,state,mobile,zip,paddress,pcity,pstate,cmy,pzip,ptype,numofbeds,numofbaths,shortdescription,uploaded_file,uploaded_file2,uploaded_file3)values('".$_REQUEST['name']."','".$_REQUEST['ntype']."','".$_REQUEST['address']."','".$_REQUEST['email']."','".$_REQUEST['city']."','".$_REQUEST['phone']."','".$_REQUEST['state']."','".$_REQUEST['mobile']."','".$_REQUEST['zip']."','".$_REQUEST['paddress']."','".$_REQUEST['pcity']."','".$_REQUEST['pstate']."','".$_REQUEST['cmy']."','".$_REQUEST['pzip']."','".$_REQUEST['ptype']."','".$_REQUEST['numofbeds']."','".$_REQUEST['numofbaths']."','".$_REQUEST['shortdescription']."','". $name."','". $name2."','". $name3."')";

 

 

$result=mysql_query($query);

if($result)

{

echo "<h3><font color='#8e4e11' size='6'>Thanks for adding.</font>";

 

 

}

echo $name;

echo $name2;

echo $name3;

  }

  function getNonExistingFilename($uploadFilesTo, $name)

  {

      if (!file_exists($uploadFilesTo . '/' . $name))

          return $name;

   

      return getNonExistingFilename($uploadFilesTo, rand(100, 200) . '_' . $name);

  }

 

 

 

 

 

?>

 

    </p>

  <p> </p>

</div>

  </form></div>

 

I had the same problem b4 with picture files I had to put

 

ini_set ('upload_max_filesize','10M');

 

 

at the top of my php submit code as most servers don't allow large file uploads unless they are forced to you could try to increase it to more than ten but don;t know if it will allow that

try this

 

ini_set ('upload_max_filesize','10M');


$fileatt_name = $_FILES['uploaded_file']['name'];

$name = mysql_real_escape_string($fileatt_name[0]);
$name2 = mysql_real_escape_string($fileatt_name[1]);
$name3 = mysql_real_escape_string($fileatt_name[2]);


foreach ($_FILES["uploaded_file"]["error"] as $key => $error) { 
        if ($error == UPLOAD_ERR_OK) { 
$fileatt = $_FILES['uploaded_file']['tmp_name'][$key];
$fileatt_type = $_FILES['uploaded_file']['type'][$key];
$fileatt_name = $_FILES['uploaded_file']['name'][$key]; 

       
        // attachment

        $fp = fopen($fileatt, 'rb');
        $data = fread($fp, filesize($fileatt));
        fclose($fp);
        $data = chunk_split(base64_encode($data));

move_uploaded_file($fileatt, "videos/$fileatt_name"); 
       
    } 
}

 

You could try this but i would advise you add more fields to your database too

 

I noticed you have uploaded_file, only once

 

try adding so you have

 

uploaded_file1, uploaded_file2, uploaded_file3 in your databas einsert

 

as long as the videos folder is in the same directory this should work if not change it to ./../videos if it is back a folder

 

this should work but i can't promise it worked for me with pictures maybe try to modify it a bit

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.