Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 07-23-2007, 01:27 PM   #1 (permalink)
Salchester
Salchester
 
Salchester's Avatar
 
Join Date: Jul 2005
Location: In a house
Posts: 230
Salchester is an unknown quantity at this point
Upload Videos

Hi Everyone,

How do I change the following code, to except .wmv files like it does images?

Code:
<?php
$con = mysql_connect("localhost","peter","abc123");
if (!$con)
{
  die('Could not connect: ' . mysql_error());
}

mysql_select_db("TS", $con);

      $sql="INSERT INTO Images (caption)
      VALUES
      ('$_POST[caption]')";  

if (($_FILES["file"]["type"] == "image/bmp")
|| ($_FILES["file"]["type"] == "image/jpeg")
&& ($_FILES["file"]["size"] < 90000))
{
  if ($_FILES["file"]["error"] > 0)
  {
    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
  }
  else
  {
    echo "Upload: " . $_FILES["file"]["name"] . "<br />";
    echo "Type: " . $_FILES["file"]["type"] . "<br />";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";

    if (file_exists("upload/" . $_FILES["file"]["name"]))
    {
      echo $_FILES["file"]["name"] . " already exists. ";
    }
    else
    {
      $file = ("upload/" . $_FILES["file"]["name"]);
      move_uploaded_file($_FILES["file"]["tmp_name"],
      "upload/" . $_FILES["file"]["name"]);
      echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
      
      mysql_query("INSERT INTO Videos (caption, path)
      VALUES('$_POST[caption]','$file')");


    }
  }
}
else
{
  echo "Invalid file";
}
?>
__________________
Many Thanks, in advance!

Salchester.
The Future Is Here - Are You Ready?
Salchester is offline   Reply With Quote
Old 07-23-2007, 01:29 PM   #2 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,161
Belisarius is on a distinguished road
Well, what have you tried so far to get it to work?
__________________
GitS
Belisarius is offline   Reply With Quote
Old 07-23-2007, 01:31 PM   #3 (permalink)
Salchester
Salchester
 
Salchester's Avatar
 
Join Date: Jul 2005
Location: In a house
Posts: 230
Salchester is an unknown quantity at this point
That works, but how do i allow .wmv files?
__________________
Many Thanks, in advance!

Salchester.
The Future Is Here - Are You Ready?
Salchester is offline   Reply With Quote
Old 07-23-2007, 01:34 PM   #4 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,161
Belisarius is on a distinguished road
Well, what have you tried so far to get it to work with .wmv files?
__________________
GitS
Belisarius is offline   Reply With Quote
Old 07-23-2007, 09:59 PM   #5 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,705
redhead is on a distinguished road
I would suggest looking at your own bold lines there, and extend it to have wmv files aswell..
If you dont know what $_FILE['file']['type'] it is expressed as, then perhaps make a pseudo code which dosn't upload but only displays this info..
Fom there just alter your acceptance demands to fit what this variable holds.

Or perhaps I would swing by php.net and look up the $_FILE variable to see if it is mentioned anywhere, or perhaps take a look at move_uploaded_file() description there to see if anyone has been so kind to show a small example which takes videos...

Aaarrg, now I used up my salch-quota for this week helping you salchester, hope you can use some of the pointers given here, and next time think in that same direction as I've just described.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
FTP upload script ericyong88 PHP 2 04-21-2006 03:10 AM
php script that can upload binary data infinite_root PHP 9 08-27-2004 06:03 PM
File upload NirTivAal PHP 5 03-02-2004 01:29 PM
File upload error(PHP) jacob PHP 8 08-16-2002 06:16 AM


All times are GMT -8. The time now is 04:07 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting