Web Analytics Made Easy -
StatCounter Video Upload Script Error--I'm Lost! - CodingForum

Announcement

Collapse
No announcement yet.

Video Upload Script Error--I'm Lost!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Video Upload Script Error--I'm Lost!

    Code:
    <?php
    include("include/config.php");
    session_start();
    include("include/function.php");
    chk_member_login();
    isMailVerified();
    if($config['enable_package']=="yes")
    {
            check_subscriber(100);
    }
    
    
    if($_REQUEST[action_upload]!="")
    {
            if($_REQUEST[field_myvideo_title]==""){
    			$err="Upload: Please Provide a video title.";
    		}
            elseif($_REQUEST[field_myvideo_descr]==""){
    			$err="Upload: Please Provide a video description.";
    		}
            elseif($_REQUEST[field_myvideo_keywords]==""){
    			$err="Upload: Please provide tag/s.";
    		}
            elseif(count($_REQUEST[chlist])<1 || count($_REQUEST[chlist])>3){
    			$err="Upload: Please check (1 to 3) channel/s.";
    		}
    
            if($err==""){
    			$page = "second";
    			STemplate::assign('secondpage',"second");
    			$listch=implode("|",$_REQUEST[chlist]);
    			STemplate::assign('listch',$listch);
    			$var = "<script language=javascript>
    					var field_myvideo_title = $_REQUEST[field_myvideo_title];
    					var field_myvideo_descr = $_REQUEST[field_myvideo_descr];
    					var field_myvideo_keywords = $_REQUEST[field_myvideo_keywords];
    					var listch = $listch;
    
    					</script>";
    			STemplate::assign("var", $var);
            }
    }
    if($_POST[upload_final]!="")
    {
            if($_FILES['field_uploadfile']['tmp_name']=="") $err="Please provide the video location.";
            if($err=="" && $_FILES['field_uploadfile']['tmp_name']!="")
                    {
                    $p=$_FILES['field_uploadfile']['name'];
                    $pos=strrpos($p,".");
                    $ph=strtolower(substr($p,$pos+1,strlen($p)-$pos));
                    /* Space in Megabytes (MB) */
                    $space = round($_FILES['field_uploadfile']['size']/(1024*1024));
                    if($config['enable_package']=="yes")
                    {
                            check_subscriber($space);
                    }
                    
                    if(($ph!="mpg" && $ph!="avi" && $ph!="mpeg" && $ph!="wmv" && $ph!="rm" && $ph!="dat") || $space>$config[max_video_size])
                    $err="Invalid Video Format.";
                    }
    
            if($err=="")
            {
                    $sql="insert into video set
                            UID=$_SESSION[UID],
                            title='$_REQUEST[field_myvideo_title]',
                            description='$_REQUEST[field_myvideo_descr]',
                            keyword='$_REQUEST[field_myvideo_keywords]',
                            channel='0|$_REQUEST[listch]|0',
                            space = '$_REQUEST[space]',
                            addtime='".time()."',
                            adddate='".date("Y-m-d")."',
                            vkey='".mt_rand()."',
                            type='$_REQUEST[field_privacy]',
                            filehome='$_REQUEST[p]'";
                    $conn->execute($sql);
                    $vid=mysql_insert_id();
                    $vdoname=$vid.".".$ph;
                 
                        if(isset($_FILES['field_uploadfile']['tmp_name']) && is_uploaded_file($_FILES['field_uploadfile']['tmp_name']))
                        {
    						$ff = $config[vdodir]."/".$vdoname;
    						if(move_uploaded_file($_FILES['field_uploadfile']['tmp_name'], $ff))
    						{	$mov = new ffmpeg_movie($ff);
    							video_to_frame($ff,$vid,&$mov,$listch[0]);
    							$duration=$mov->getDuration();
    							exec("$config[ffmpeg] -i $config[vdodir]/$vdoname -acodec mp3 -ar 22050 -ab 32 -f flv $config[flvdodir]/".$vid.".flv");
    						}
                           
                        }
                    //END
    
                    $key=substr(md5($vid),11,20);
                    $sql="update video set
                            vdoname='$vdoname',
                            flvdoname='".$vid.".flv',
                            duration='$duration',
                            vkey='$key' WHERE VID=$vid";
                    $conn->execute($sql);
            
                    if($config['enable_package']=="yes")
                    {
                            $sql = "update subscriber set used_space=used_space+$space, used_bw=used_bw+$space, total_video=total_video+1 where UID=$_SESSION[UID]";
                            $conn->execute($sql);
                    }
            
                    header("Location:$config[baseurl]/upload_success.php?viewkey=$key&upload=yes&vid=$vid");
            }
    }
    
    
    STemplate::assign('err',$err);
    STemplate::assign('msg',$msg);
    STemplate::assign('head_bottom',"blank.tpl");
    STemplate::display('head1.tpl');
    STemplate::display('err_msg.tpl');
    STemplate::display('upload.tpl');
    STemplate::display('footer.tpl');
    ?>
    This upload script puts out a 2 page upload form. The first page asks for a title/descript/keywords & selection of channels you'd like to put the video on. Then you hit a next button and it brings yo to the 2nd output page. This is where you upload your video. When you hit upload it takes a few minutes and when it is doen it ALWAYS spits out the following error. When I look at the code surrounding this error I can not figure out what is actually triggering it. If anyone could tell me why it is giving me the error..that may help...LOL...I think.

    The error:
    Please provide the video location.

    Code surrounding it:
    }
    }
    if($_POST[upload_final]!="")
    {
    if($_FILES['field_uploadfile']['tmp_name']=="") $err="Please provide the video location.";
    if($err=="" && $_FILES['field_uploadfile']['tmp_name']!="")
    http://www.viagrabelgiquefr.com/

  • #2
    We need to see the html code for the upload form too in order to debug this visually for you.

    Comment


    • #3
      upload templates

      this is the upload tempalte
      Code:
      {if $secondpage ne "second" and $smarty.request.upload_final eq ""}
      <table>
      <tr>
      <td height="24" valign=top align=center><table width="760"  border="0" cellspacing="0" cellpadding="0">
                                        <tr>
                                          <td width="5" height="24" background="images/nv_2_l.jpg" valign=top><img src="images/nv_2_l.jpg" width="5" height="24" alt=""></td>
                                          <th background="images/nv_2_bg.jpg" align=left width=760><span class="white_bold" valign=top align=left>Video Upload (Step 1 of 2)</span></th>
                                          <td width="5" background="images/nv_2_r.jpg"><img src="images/nv_2_r.jpg" width="5" height="24" alt=""></td>
                                        </tr>
                                    </table></td>
      
      </tr></table>
      
      <FORM id=theForm name=theForm action="{$baseurl}/upload.php" method=post encType=multipart/form-data>
      <TABLE cellSpacing=0 cellPadding=5 width="100%" border=0><TBODY>
      <TR>
      <TD align=right width=200><SPAN class=label><NOBR>Title:</NOBR></SPAN></TD>
      <TD><INPUT maxLength=60 size=40 name="field_myvideo_title" value="{$smarty.request.field_myvideo_title}"></TD>
      </TR>
      <TR>
      <TD vAlign=top align=right><SPAN class=label><NOBR>Description:</NOBR> </SPAN></TD>
      <TD><TEXTAREA name="field_myvideo_descr" rows=4 cols=50>{$smarty.request.field_myvideo_descr}</TEXTAREA></TD>
      </TR>
      <TR vAlign=top>
      <TD align=right><SPAN class=label><NOBR>Tags:</NOBR> </SPAN></TD>
      <TD><INPUT maxLength=120 size=40 name="field_myvideo_keywords" value="{$smarty.request.field_myvideo_keywords}">
      <DIV class=formFieldInfo><STRONG>Enter one or more tags, separated
      by spaces.</STRONG> <BR>Tags are simply keywords used to describe
      your video so they are easily searched and organized. For example,
      if you have a surfing video, you might tag it: surfing beach
      waves.<BR></DIV></TD>
      </TR>
      <TR vAlign=top>
      <TD align=right><SPAN class=label><NOBR>Video Channels:</NOBR></SPAN></TD>
      <TD>
              <TABLE><TBODY><TR><TD vAlign=top>
              {insert name=list_channel assign=chinfo vid=$VID}
              {section name=i loop=$chinfo}
              <INPUT type=checkbox name=chlist[] value={$chinfo[i].id}>{$chinfo[i].ch}<BR>
              {/section}
              </TD></TR></TBODY></TABLE>
      
      <DIV class=formFieldInfo><STRONG>Select between one to three
      channels that best describe your video.</STRONG><BR>It helps to use
      relevant channels so that others can find your video!</DIV>
      </TD>
      </TR>
      <TR>
      <TD align=right>&nbsp;</TD>
      <TD><INPUT type=submit value="Continue ->" name=action_upload></TD></TR>
      </TBODY></TABLE>
      </FORM>
      
      {else}
      <table>
      <tr>
      <td height="24" valign=top align=center><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                                        <tr>
                                          <td width="5" height="24" background="images/nv_2_l.jpg" valign=top><img src="images/nv_2_l.jpg" width="5" height="24" alt=""></td>
                                          <th background="images/nv_2_bg.jpg" align=left width=760><span class="white_bold" valign=top align=left>Video Upload (Step 2 of 2)</span></th>
                                          <td width="5" background="images/nv_2_r.jpg"><img src="images/nv_2_r.jpg" width="5" height="24" alt=""></td>
                                        </tr>
                                    </table></td>
      
      </tr></table>
      
      
      
      <FORM id=theForm name=theForm action="{$baseurl}/upload.php" method=post encType=multipart/form-data>
      <table width="100%" cellpadding="5" cellspacing="0" border="0">
      <tr valign="top">
              <td width="200" align="right"><span class="label">File:</span></td>
              <td><div class="formHighlight"><input type="hidden" name="MAX_FILE_SIZE" value="104857600">
              <input type="file" name="field_uploadfile" size="30">
              <div class="formHighlightText"><strong>Max file size: 100 MB. No copyrighted or obscene material.</strong>
              <br>After uploading, you can edit or remove this video at anytime under the "My Videos" link on the top of the page.</div></div></td>
      </tr>
      <tr>
              <td align="right"><span class="label">Broadcast:</span></td>
              <td>
              <table cellpadding="1" cellspacing="0" border="0">
              <tr>
                      <td><input name="field_privacy" type="radio" value="public" checked></td>
                      <td><span class="bold">Public:</span> Share your video with the world! (Recommended)</td>
                      </tr>
              </table>
              </td>
              </tr>
              <tr>
              <td align="right"><span class="label">&nbsp;</span></td>
              <td>
                      <table cellpadding="1" cellspacing="0" border="0">
                      <tr>
                      <td><input name="field_privacy" type="radio" value="private"></td>
                      <td><span class="bold">Private:</span> Only viewable by you and those you share the video with.</td>
                      </tr>
                      </table>
              </td>
              </tr>
              <tr>
                      <td colspan="2">&nbsp;</td>
              </tr>
              <tr>
              <td align="right">&nbsp;</td>
              <td>
              <span class="bold">PLEASE BE PATIENT, THIS MAY TAKE SEVERAL MINUTES.
                      <br>ONCE COMPLETED, YOU WILL SEE A CONFIRMATION MESSAGE.<br><br></span>
                      <input type="hidden" name="field_myvideo_keywords" value="{$smarty.request.field_myvideo_keywords}">
                      <input type="hidden" name="field_myvideo_title" value="{$smarty.request.field_myvideo_title}">
                      <input type="hidden" name="field_myvideo_descr" value="{$smarty.request.field_myvideo_descr}">
                      <input type="hidden" name="listch" value="{$listch}">
                      <input name="upload_final" type="submit" value="Upload Video" ><!-- onclick='this.disabled = true;' -->
                      <span id="hide_stuff" style="display:none;" class="bold">
                      <table><tr>
                      <td valign=middle> <img  src="{$imgurl}/LoadingGraphic.gif"></img></td><td valign=middle><font size=4>Uploading..</font></td>
                      </tr></table>
                      </span> </td></tr></table>
      </FORM>
      {/if}
      this is the uploadsuccess template
      Code:
      <tr><td align="center">
      <table width=90% align="center">
      <tr><td>
      {if $smarty.request.upload eq "yes"}<SPAN class=highlight>Your video was successfully added!</SPAN>{/if}
      <BR>Your video is currently being processed and will be available to
      view in a few minutes.<BR>Want to upload more videos? <B><A
      href="{$baseurl}/upload.php">Click here</A></B>
      <BR><BR>Now that
      your video is uploaded, you can share it with others, embed it into your
      Web site (and others), and include more details. <BR><BR>
      <DIV style="FONT-WEIGHT: bold; FONT-SIZE: 14px; PADDING-BOTTOM: 10px; COLOR: #cc6633">Share
            your video (Optional):</DIV>Use the share manager application below to
            easily share your video with friends, family, and other contacts. <BR>If
            that's not your thing, you can copy and paste the video url (permalink)
            into an e-mail. <BR><BR><BR>
            <!-- KEEP THIS IN SYNC WITH WATCH.PHP! -->
            <DIV style="PADDING-BOTTOM: 10px">
            <TABLE>
              <TBODY>
              <TR>
              <TD vAlign=top align=left
              width=376><!-- Begin Video URL Section--><SPAN
              style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-WEIGHT: bold; FONT-SIZE: 12px; PADDING-BOTTOM: 5px; COLOR: #cc6633; PADDING-TOP: 5px">Video
              URL (Permalink):</SPAN> &nbsp;<B>Email or link it!</B> <BR><B><A
              href="javascript:openShare()">Share this video with your
              friends</A></B> <BR>
              <DIV style="FONT-SIZE: 11px; PADDING-BOTTOM: 15px; PADDING-TOP: 5px">
              <INPUT style="FONT-SIZE: 10px; WIDTH: 290px; TEXT-ALIGN: center"
              onclick=javascript:document.linkForm.video_link.focus();document.linkForm.video_link.select();
              readOnly value="{$baseurl}/view_video.php?viewkey={$smarty.request.viewkey}" name=video_link>
              </DIV><!--End Video URL Section--><BR><!--Begin Embed your video Section--><SPAN
              style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-WEIGHT: bold; FONT-SIZE: 12px; PADDING-BOTTOM: 5px; COLOR: #cc6633; PADDING-TOP: 5px">Embed
              your video:</SPAN> &nbsp;<B>Put this video on your Web site!</B>
              <B>Copy and paste the code below to embed the video.</B>
      
              <DIV style="FONT-SIZE: 11px; PADDING-BOTTOM: 8px; PADDING-TOP: 5px">
              
      	<TEXTAREA style="FONT-SIZE: 11px; WIDTH: 290px; FONT-FAMILY: Arial, Helvetica, sans-serif; HEIGHT: 120px;
              TEXT-ALIGN: center" onclick=javascript:document.linkForm.video_play.focus();
              document.linkForm.video_play.select(); name=video_play readOnly wrap=physical><object type="application/x-shockwave-flash" width="320" height="240"
                              wmode="transparent" data="{$flvdourl}/flvplayer.swf?file={$flvdourl}/{$vidid}.flv&autoStart=false">
                              <param name="movie" value="{$flvdourl}/flvplayer.swf?file={$flvdourl}/{$vidid}.flv&autoStart=false" />
                              <param name="wmode" value="transparent" />
                      </object></TEXTAREA>
              
      	</DIV>
      
              <TABLE cellSpacing=0 cellPadding=5 border=0>
              <FORM action="{$baseurl}/upload_success.php?viewkey={$smarty.request.viewkey}" method=post>
              <INPUT type=hidden value={$smarty.request.viewkey} name=viewkey>
              <TBODY>
              <TR>
                <TD colSpan=2>
                  <DIV class=tableSubTitle>Date &amp; Location Details
                  (Optional):</DIV></TD></TR>
              <TR vAlign=top>
                <TD align=right><SPAN class=label><NOBR>Date Recorded:</NOBR>
                </SPAN></TD>
                <TD>
                      <SELECT name=month><OPTION>mm</OPTION><OPTION>{$months}</OPTION></SELECT>
                      <SELECT name=day><OPTION>dd</OPTION><OPTION>{$days}</OPTION></SELECT>
                      <SELECT name=year><OPTION>yyyy</OPTION><OPTION>{$years}</OPTION></SELECT>
                </TD></TR>
              <TR vAlign=top>
                <TD align=right><SPAN class=label><NOBR>Location Recorded:</NOBR>
                  </SPAN></TD>
                <TD><INPUT maxLength=255 size=40 name=field_address value="{$smarty.request.field_address}">
                  <DIV class=formFieldInfo>Examples: "165 University Ave, Palo Alto,
                  CA" &nbsp; "New York City, NY" &nbsp; "Tokyo"</DIV></TD></TR>
              <TR vAlign=top>
              <TD align=right><SPAN class=label><NOBR>Country:</NOBR> </SPAN></TD>
              <TD>
                      <SELECT name=country>
                      <OPTION>Select Country</OPTION>
                      <OPTION>{$country}</OPTION>
                      </SELECT>
              </TD>
              </TR>
              <TR>
                <TD align=right>&nbsp;</TD>
                <TD><INPUT type=hidden value=1 name=action_update>
                <INPUT type=submit value="Update Video" name="action_update">
              </TD></TR></FORM></TBODY></TABLE></DIV>
      </TD></TR></TBODY></TABLE>
      
      </td></tr>
      </table>
      
      </td></tr>
      http://www.viagrabelgiquefr.com/

      Comment


      • #4
        *bump*
        http://www.viagrabelgiquefr.com/

        Comment


        • #5
          When you display the $_FILES array, what do you see? And is it different than what you're supposed to see? That's where you should start debugging this problem.

          Comment


          • #6
            i guess I'm gonna have to end up paying someone to figure this out then because my knowledge is limited and that reply looked like greek to me...LOL...

            when presented with solutions I can usually fix it but this one is maybe to complex for me. THANKS!!!!
            http://www.viagrabelgiquefr.com/

            Comment


            • #7
              would the SMARTY template engine have anything to do with this mess? I'm trying to see if there are any inconsistencies in it....
              http://www.viagrabelgiquefr.com/

              Comment


              • #8
                Ever find the issue?

                I am facing the same error. The strange part is if I add a file type mov to the upload.php code then that file will upload and move past this (to another error), but I am lost as to why the predefined file types get this error.


                if($_POST[upload_final]!="")
                {
                if($_FILES['field_uploadfile']['tmp_name']=="") $err="Please provide the video location.";
                if($err=="" && $_FILES['field_uploadfile']['tmp_name']!="")
                {
                $p=$_FILES['field_uploadfile']['name'];
                $pos=strrpos($p,".");
                $ph=strtolower(substr($p,$pos+1,strlen($p)-$pos));
                /* Space in Megabytes (MB) */
                $space = round($_FILES['field_uploadfile']['size']/(1024*1024));
                if($config['enable_package']=="yes")
                {
                check_subscriber($space);
                }

                if(($ph!="mpg" && $ph!="avi" && $ph!="mpeg" && $ph!="wmv" && $ph!="rm" && $ph!="dat") || $space>$config[max_video_size])
                $err="Invalid Video Format.";
                }

                Comment


                • #9
                  A little more info

                  Ok so it seems to be getting caught up in files over 1MB, it just happed to be that the .mov that I added was below 1MB which is why adding the new file type to the upload.php seemed to work.


                  So my question, why is this error only happening with files over 1MB? Where is this setting? Etc...

                  Comment


                  • #10
                    I found the issue. You need to up the file upload size limits in your php.ini file:

                    memory_limit = 200M
                    file_uploads = On
                    post_max_size = 25M
                    upload_max_filesize = 20M

                    Comment


                    • #11
                      im unable to locate php.ini

                      :-/

                      Comment


                      • #12
                        Do you have access to the server (i.e. is it on your own computer) or are you purchasing a hosting package?

                        If you are purchasing hosting, you can't access php.ini, but you may want to look into ini_set();...

                        If you're on your own computer, make a simple php file:
                        PHP Code:
                        <?php
                        phpinfo
                        ();
                        ?>
                        and then access it through your browser. It will show tons of info about your PHP settings. The path to your PHP.ini file should be shown near the top (the sixth row of info)

                        HTH
                        Dan
                        PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

                        Don't forget to save everyone time and mark your thread as Resolved :)

                        "Also note that it is your responsibility to die() if necessary."

                        DON'T USE THE MYSQL_ EXTENSION

                        Comment


                        • #13
                          look this site is for men and women that serve the world either at home ...military, EMT, Firefighter, or police.. the budget for the site is extremely low and already gone past what i can afford.. i have the script .. i just need someone willing to volunteer there time on helping the site get completed..

                          i am willing to provide free web hosting to anyone that can fix the site to working order and give credit to them for complete the project..

                          thanks.. please PM me if your willing to help..

                          PS i do have root access to the server..

                          Comment


                          • #14
                            I also have you tube clone and apply the solution as given by MBVsite and got success in uploading videos less than 100 mb but i want my script to upload more than 100 mb videos. i even changed php.in values to

                            the memory_limit = 5000M
                            file_uploads = On
                            post_max_size = 500M
                            upload_max_filesize = 500M

                            and getting the same error "Please provide the video location."

                            I appreciate if some one will help me and let me know how i can do this.

                            Comment

                            Working...
                            X