problem occuring when I am trying to upload multiple video file with one submission

Discussion in 'PHP' started by ash007, Mar 23, 2009.

  1. #1
    Hi,

    I when I am trying to upload multiple video files with one form submission,video file is not uploaing.The same code is working for image uploading.I created the .htaccess file and changed the max_file_size....

    here I am including the code for your kind ref...
    please go through this....and kindly help me to rectify the problem..

    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">&nbsp;</td>
    <td width="88">&nbsp;</td>
    <td width="152">&nbsp;</td>
    </tr>
    <tr>
    <td class="headingstyle style1">&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td> <div align="center"><strong>Contact Information </strong></div></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</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>&nbsp;</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>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td height="26" colspan="2"><div align="center"><strong>Property Information </strong></div></td>
    <td>&nbsp;</td>
    <td>&nbsp;</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>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td><input type=hidden name=MAX_FILE_SIZE value=150000>
    <input type=hidden name=completed value=1></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td height="24" colspan="2"><div align="center"><strong>Upload Picture/Video</strong></div></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td height="34">&nbsp;</td>
    <td height="34"><input type="file" name="uploaded_file[]" /></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td height="31">&nbsp;</td>
    <td height="31"><input type="file" name="uploaded_file[]" /></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td height="33">&nbsp;</td>
    <td height="33"><input type="file" name="uploaded_file[]" /></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td height="33">Short Description </td>
    <td height="33"><textarea name="shortdescription" cols="25" rows="3" id="shortdescription"></textarea></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td height="31" colspan="2"></td>
    <td>&nbsp;</td>
    <td>&nbsp;</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>&nbsp;</p>
    </div>
    </form></div>
    ---------------------------
    .htaccess file
    ----------------
    RewriteEngine on
    php_value upload_max_filesize 35M
    php_value post_max_size 35M
    php_value max_execution_time 900
    php_value max_input_time 900
     
    ash007, Mar 23, 2009 IP
  2. joep1978

    joep1978 Peon

    Messages:
    30
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    In the second form you need enctype="multipart/form-data" as well
     
    joep1978, Mar 23, 2009 IP
  3. GreatMetro

    GreatMetro Peon

    Messages:
    117
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    GreatMetro, Mar 23, 2009 IP
  4. kenfrank

    kenfrank Peon

    Messages:
    28
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Try increasing the memory limit with ini_set(), see: http://uk3.php.net/ini_set (the first arg is 'memory_limit' and the second is a string like '128M' for 128 megabytes).

    Also try increasing how long your scripts can run before terminating (default is often 30 seconds, but be VERY careful about increasing this!)
     
    kenfrank, Mar 24, 2009 IP