Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Simple single file upload how is this done securely?; I also need a script for this
Old 09-12-2007, 01:33 AM Simple single file upload how is this done securely?; I also need a script for this
goheadtry's Avatar
Webmaster Talker

Posts: 726
Name: John
Location: United States of America, California
Trades: 0
Okay I need an upload script that is secure and has a max upload size of
89128960 byte and only uploads one file and makes sure that the type is video type before allowing

and uploads to directory path /home/forbushj/uploadvidd/

I have found many tutorials where the code does not work so your help would be greatly appreciated
__________________
Free $1 gift card when you signup at
Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

goheadtry is offline
Reply With Quote
View Public Profile Visit goheadtry's homepage!
 
 
Register now for full access!
Old 09-12-2007, 09:03 AM Re: Simple single file upload how is this done securely?; I also need a script for th
metho's Avatar
Ultra Talker

Posts: 481
Location: Gold Coast - Brisbane QLD, Australia
Trades: 0
Uploading files of that size requires the server to be configured to allow http uploads that big and the execution time required to complete the upload. Then php has to be configured to permit a file that big to upload and to extend script execution time for the duration of the transfer. Before you even get to the script, you have to consider the lowest upload speed of a user's connection then factor that speed into the server and php configurations.

If configuring the server isn't possible on your account, ftp via php may be an option.

The scripting side is pretty simple; the php forum is full of large file upload scripts. Validating the file format before uploading is a bit trickier; that can only be done with javascript. But again, you'll find working examples in the javascript forum. Did you try a search? The above JS thread looks like it'd do the job nicely.

Secure? SSL perhaps? Or were you thinking about file permissions and what not?
__________________
I do
Please login or register to view this content. Registration is FREE
based.
Spend a lot of time in
Please login or register to view this content. Registration is FREE
.
And
Please login or register to view this content. Registration is FREE
chews up the rest.
metho is offline
Reply With Quote
View Public Profile Visit metho's homepage!
 
Old 09-12-2007, 09:06 PM Re: Simple single file upload how is this done securely?; I also need a script for th
goheadtry's Avatar
Webmaster Talker

Posts: 726
Name: John
Location: United States of America, California
Trades: 0
Okay but what are the math formulas to figure this out
__________________
Free $1 gift card when you signup at
Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

goheadtry is offline
Reply With Quote
View Public Profile Visit goheadtry's homepage!
 
Old 09-13-2007, 12:18 AM Re: Simple single file upload how is this done securely?; I also need a script for th
goheadtry's Avatar
Webmaster Talker

Posts: 726
Name: John
Location: United States of America, California
Trades: 0
My video upload script is near completion but I can't figure out why the MYSQL part is working could somebody please check this and let me know also I want it to write to my sql only when successful I can't figure that out I have included the source code for the file uploadit.php

and I need some help to make sure that this code will work correctly and validate so that it can only use certain file extesions without them being case sensitive

Please help me I have included the code


PHP Code:
<link href="http://www.technologyforever.com/test.css" rel="stylesheet" type="text/css" />
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
  <tr>
    <form action="uploadit.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
      <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
          <tr>
            <td colspan="2"><strong>Single File Upload </strong></td>
          </tr>
          <tr>
            <td width="18%">Video Name:</td>
            <td width="82%"><label>
              <input type="text" name="vidname" id="vidname" />
            </label></td>
          </tr>
          <tr>
            <td>Video Category</td>
            <td><label>
              <select name="select" id="select">
                <option value="1" selected="selected">---------</option>
                <option value="1">Autos/Vehicles</option>
                <option value="2">Comedy</option>
                <option value="3">Entertainment</option>
                <option value="4">Film/Animation</option>
                <option value="5">Gadgets/Games</option>
                <option value="6">Howto/DIY</option>
                <option value="7">Music</option>
                <option value="8">News/ Politics</option>
                <option value="9">People/Blogs</option>
                <option value="10">Pets/Animals</option>
                <option value="11">Sports</option>
                <option value="12">Travel/ Places</option>
                <option value="13">Other</option>
                                                                                    </select>
              <span class="style11">Select a category</span></label></td>
          </tr>
          <tr>
            <td><p>Video Description</p>
              <p>&nbsp;</p></td>
            <td><textarea name="viddes" id="viddes" cols="45" rows="5"></textarea></td>
          </tr>
          <tr>
            <td>Website</td>
            <td><label>
              <input name="srcof" type="text" id="srcof" value="http://www.technologyforever.com" size="70" maxlength="100" />
            If not leave as is</label></td>
          </tr>
          <tr>
            <td><p>Select file </p>
              <p>&nbsp;</p>              </td>
            <td><input name="ufile" type="file" id="ufile" size="50" /></td>
          </tr>
          <tr>
            <td colspan="2" align="center"><input type="submit" name="Submit" value="Upload" /></td>
          </tr>
      </table></td>
    </form>
  </tr>
</table>




<?php
//set where yzzou want to store files
//in this example we keep file in folder upload
//$HTTP_POST_FILES['ufile']['name']; = upload file name
//for example upload file name cartoon.gif . $path will be upload/cartoon.gif
$path"uploadvidd/".$HTTP_POST_FILES['ufile']['name'];
if(
$ufile !=none)
{
if (
file_exists($path)) {
$path"uploadvidd/1".$HTTP_POST_FILES['ufile']['name'];
}
if(
copy($HTTP_POST_FILES['ufile']['tmp_name'], $path))
{
$input $_GET['input'];
list(
$usec$sec) = explode(' 'microtime());
$output str_replace('.''', (float)$usec + (float)$sec);
exec('ffmpeg -i /home/forbushj/public_html/'.$path.' -s 150×100 -ss 30 -vframes 1 -f image2 /home/forbushj/public_html/pic/video/'.$output.'.jpg');  
exec('ffmpeg -i /home/forbushj/public_html/'.$path.' -ar 22050 -ab 32 -f flv -s 320x240 /home/forbushj/public_html/vidd/'.$output.'.flv');
echo 
"Successful<BR/>";

}
else
{
echo 
"Error";
}
}

// If the submit button has been pressed
   
if (isset($_POST['submit'])) {
      
// Connect to the server and select the database
      
$linkID = @mysql_connect("localhost","MYSECRETLOGIN","MYSECRETpASSWORD") or die("Could not connect to MySQL server");
      @
mysql_select_db("video") or die("Could not select database");

      
// Retrieve the posted product information.
      
$titlev $_POST['vidname'];
      
$descrv $_POST['viddes'];
      
$srcv $_POST['srcof'];
     

      
// Insert the product information into the product table
      
$query "INSERT INTO product SET id='', title='$titlev', descr='$descrv', pic='.$output.'.jpg', locat='.$output.'.flv' src='$srcv'";
      
$result mysql_query($query);

      
// Display an appropriate message
      
if ($result) echo "<p>sdkgsdjkfgs</p>";
      else echo 
"<p>There was a problem inserting the product!</p>";

      
mysql_close();
   }


   
?>
__________________
Free $1 gift card when you signup at
Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

goheadtry is offline
Reply With Quote
View Public Profile Visit goheadtry's homepage!
 
Old 09-13-2007, 12:50 AM Re: Simple single file upload how is this done securely?; I also need a script for th
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,898
Name: Keith Marshall
Location: Connecticut
Trades: 0
The mysql queries could go within the part along side where the exec() function is being called. The uploaded filename could also be split by the . and have the end element be checked against an array of allowed file extentions.
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 09-13-2007, 09:42 PM I am having a problem with the mysql part everything else works
goheadtry's Avatar
Webmaster Talker

Posts: 726
Name: John
Location: United States of America, California
Trades: 0
I am having a problem with the mysql part everything else works
I have posted the code below can someone tell me what is wrong and help me fix it If I have not given you talkupation lately meaning if it will allow me I will give some to the one that helps me.

PHP Code:
<link href="http://www.technologyforever.com/test.css" rel="stylesheet" type="text/css" />
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
  <tr>
    <form action="uploadit.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
      <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
          <tr>
            <td colspan="2"><strong>Single File Upload </strong></td>
          </tr>
          <tr>
            <td width="18%">Video Name:</td>
            <td width="82%"><label>
              <input type="text" name="vidname" id="vidname" />
            </label></td>
          </tr>
          <tr>
            <td>Video Category</td>
            <td><label>
              <select name="select" id="select">
                <option value="1" selected="selected">---------</option>
                <option value="1">Autos/Vehicles</option>
                <option value="2">Comedy</option>
                <option value="3">Entertainment</option>
                <option value="4">Film/Animation</option>
                <option value="5">Gadgets/Games</option>
                <option value="6">Howto/DIY</option>
                <option value="7">Music</option>
                <option value="8">News/ Politics</option>
                <option value="9">People/Blogs</option>
                <option value="10">Pets/Animals</option>
                <option value="11">Sports</option>
                <option value="12">Travel/ Places</option>
                <option value="13">Other</option>
              </select>
              <span class="style11">Select a category</span></label></td>
          </tr>
          <tr>
            <td><p>Video Description</p>
              <p>&nbsp;</p></td>
            <td><textarea name="viddes" id="viddes" cols="45" rows="5"></textarea></td>
          </tr>
          <tr>
            <td>Website</td>
            <td><label>
              <input name="srcof" type="text" id="srcof" value="http://www.technologyforever.com" size="70" maxlength="100" />
            If not leave as is</label></td>
          </tr>
          <tr>
            <td><p>Select file </p>
              <p>&nbsp;</p>              </td>
            <td><input name="ufile" type="file" id="ufile" size="50" /></td>
          </tr>
          <tr>
            <td colspan="2" align="center"><input type="submit" name="Submit" value="Upload" /></td>
          </tr>
      </table></td>
    </form>
  </tr>
</table>




<?php
//set where yzzou want to store files
//in this example we keep file in folder upload
//$HTTP_POST_FILES['ufile']['name']; = upload file name
//for example upload file name cartoon.gif . $path will be upload/cartoon.gif
$path"uploadvidd/".$HTTP_POST_FILES['ufile']['name'];
if(
$ufile !=none)
{
if (
file_exists($path)) {
$path"uploadvidd/1".$HTTP_POST_FILES['ufile']['name'];
}
if(
copy($HTTP_POST_FILES['ufile']['tmp_name'], $path))
{
$input $_GET['input'];
list(
$usec$sec) = explode(' 'microtime());
$output str_replace('.''', (float)$usec + (float)$sec);
exec('ffmpeg -i /home/forbushj/public_html/'.$path.' -s 150×100 -ss 30 -vframes 1 -f image2 /home/forbushj/public_html/pic/video/'.$output.'.jpg');  
exec('ffmpeg -i /home/forbushj/public_html/'.$path.' -ar 22050 -ab 32 -f flv -s 320x240 /home/forbushj/public_html/vidd/'.$output.'.flv');
$linkID = @mysql_connect("localhost","fake_user","fake_password") or die("Could not connect to MySQL server");
      @
mysql_select_db("fake_db") or die("Could not select database");

      
// Retrieve the posted product information.
      
$titlev $_POST['vidname'];
      
$descrv $_POST['viddes'];
      
$srcv $_POST['srcof'];
     

      
// Insert the product information into the product table
      
$query "INSERT INTO video SET id='', title='$titlev', descr='$descrv', pic='.$output.'.jpg', locat='.$output.'.flv' src='$srcv'";
      
$result mysql_query($query);

      
// Display an appropriate message
      
if ($result) echo "<p>sdkgsdjkfgs</p>";
      else echo 
"<p>There was a problem inserting the product!</p>";

      
mysql_close();
echo 
"Successful<BR/>";

}
else
{
echo 
"Error";
}
}
?>
__________________
Free $1 gift card when you signup at
Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Last edited by goheadtry; 09-13-2007 at 09:43 PM..
goheadtry is offline
Reply With Quote
View Public Profile Visit goheadtry's homepage!
 
Reply     « Reply to Simple single file upload how is this done securely?; I also need a script for this
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.65227 seconds with 12 queries