Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old August 24th, 2007, 12:15 AM
Reggie
Guest
 
Posts: n/a
Default upload script

Hi am trying to create a script for users to upload small size video
clips of themselves and for it to be able to play on the media player
ive created on there user a/c.
So users to upload there video and to see it playing on there user
page.Now am a beginner to php am really trying to learn the coding but
it so difficult sometimes, but am still trying just need a bit of help
or guidance to go in the right direction.

This is my script to upload, it dose upload a file but thats all it
dose.Please help.

<?php
$target = "upload/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;

//This is our size condition
$upload_size = $_FILES['uploaded']['size'];
if ($upload_size 1000000000000)
{
echo "Your file is too large.<br>";
$ok=0;
}

//This is our limit file type condition
$upload_type = $_FILES['uploaded']['type'];
if ($upload_type =="text/php")
{
echo "No PHP files<br>";
$ok=0;
}

//Here we check that $ok was not set to 0 by an error
if ($ok==0)
{
Echo "Sorry your file was not uploaded";
}

//If everything is ok we try to upload it
else
{
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "The file ".
basename( $_FILES['uploaded']['name']). " has been uploaded";
}
else
{
echo "Sorry, there was a problem uploading your file.";
}
}
?>

  #2  
Old August 24th, 2007, 01:35 AM
Jerry Stuckle
Guest
 
Posts: n/a
Default Re: upload script

Reggie wrote:
Quote:
Hi am trying to create a script for users to upload small size video
clips of themselves and for it to be able to play on the media player
ive created on there user a/c.
So users to upload there video and to see it playing on there user
page.Now am a beginner to php am really trying to learn the coding but
it so difficult sometimes, but am still trying just need a bit of help
or guidance to go in the right direction.
>
This is my script to upload, it dose upload a file but thats all it
dose.Please help.
>
<?php
$target = "upload/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;
>
//This is our size condition
$upload_size = $_FILES['uploaded']['size'];
if ($upload_size 1000000000000)
{
echo "Your file is too large.<br>";
$ok=0;
}
>
//This is our limit file type condition
$upload_type = $_FILES['uploaded']['type'];
if ($upload_type =="text/php")
{
echo "No PHP files<br>";
$ok=0;
}
>
//Here we check that $ok was not set to 0 by an error
if ($ok==0)
{
Echo "Sorry your file was not uploaded";
}
>
//If everything is ok we try to upload it
else
{
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "The file ".
basename( $_FILES['uploaded']['name']). " has been uploaded";
}
else
{
echo "Sorry, there was a problem uploading your file.";
}
}
?>
>
So, what kind of problem are you having?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
  #3  
Old August 24th, 2007, 07:25 AM
burgermeister01@gmail.com
Guest
 
Posts: n/a
Default Re: upload script

On Aug 23, 6:08 pm, Reggie <joelregisfo...@hotmail.comwrote:
Quote:
Hi am trying to create a script for users to upload small size video
clips of themselves and for it to be able to play on the media player
ive created on there user a/c.
So users to upload there video and to see it playing on there user
page.Now am a beginner to php am really trying to learn the coding but
it so difficult sometimes, but am still trying just need a bit of help
or guidance to go in the right direction.
>
This is my script to upload, it dose upload a file but thats all it
dose.Please help.
>
<?php
$target = "upload/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;
>
//This is our size condition
$upload_size = $_FILES['uploaded']['size'];
if ($upload_size 1000000000000)
{
echo "Your file is too large.<br>";
$ok=0;
>
}
>
//This is our limit file type condition
$upload_type = $_FILES['uploaded']['type'];
if ($upload_type =="text/php")
{
echo "No PHP files<br>";
$ok=0;
>
}
>
//Here we check that $ok was not set to 0 by an error
if ($ok==0)
{
Echo "Sorry your file was not uploaded";
>
}
>
//If everything is ok we try to upload it
else
{
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "The file ".
basename( $_FILES['uploaded']['name']). " has been uploaded";}
>
else
{
echo "Sorry, there was a problem uploading your file.";}
}
>
?>
What you're describing, on the surface, sounds fairly simple, but as
I'm sure you're learning, to be truly effective requires some fairly
sophisticated programming. With that said, my first question would be
how are your user accounts set up? Right now, your script merely
uploads a file, but it does nothing to associate the file with the
user's account. You either need to set up some sort of database for
storing user data and file associations, or you need a file naming
scheme to identify which files belong to which users. Perhaps you can
use that as some kind of foundation to give us a better idea of what
it is exactly you intend to accomplish.

 

Bookmarks

Thread Tools

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles