upload script

upload script

am 24.08.2007 01:08:59 von Reggie

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.

$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.
";
$ok=0;
}

//This is our limit file type condition
$upload_type = $_FILES['uploaded']['type'];
if ($upload_type =="text/php")
{
echo "No PHP files
";
$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.";
}
}
?>

Re: upload script

am 24.08.2007 02:25:36 von Jerry Stuckle

Reggie wrote:
> 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.
>
> > $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.
";
> $ok=0;
> }
>
> //This is our limit file type condition
> $upload_type = $_FILES['uploaded']['type'];
> if ($upload_type =="text/php")
> {
> echo "No PHP files
";
> $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
==================

Re: upload script

am 24.08.2007 08:20:02 von burgermeister01

On Aug 23, 6:08 pm, Reggie wrote:
> 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.
>
> > $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.
";
> $ok=0;
>
> }
>
> //This is our limit file type condition
> $upload_type = $_FILES['uploaded']['type'];
> if ($upload_type =="text/php")
> {
> echo "No PHP files
";
> $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.