473,698 Members | 2,576 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_uploade d_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.";
}
}
?>

Aug 23 '07 #1
2 1935
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.

<?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_uploade d_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.
js*******@attgl obal.net
=============== ===
Aug 24 '07 #2
On Aug 23, 6:08 pm, Reggie <joelregisfo... @hotmail.comwro te:
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_uploade d_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.

Aug 24 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2931
by: Tihon | last post by:
Hello! I again need your help, just can't understand whats going on. Got this upload pictures form and it's having problem handling large files (~1.5 - 2 MB). Everything works fine if i just upload files, like this: copy ($myfile, $uploadfolder . "/" . $myfile_name); Everything works fine, it can process large files and everything, but i need to make sure that people only upload pictures, so i change
1
3020
by: PeterB | last post by:
Hi! I'm using Pure ASP File Upload (http://www.asp101.com/articles/jacob/scriptupload.asp) to upload a file from a client to a server. I am testing both on a local IIS and a remote server. The welcome page has a browse button (for locating your local file), a textfield where the path is displayed, and a upload button. When clicking upload a VB ASP script is run, and the outcome is displayed on a new page. 1. On my local machine I got the...
9
3831
by: Wayne Smith | last post by:
I've come up against a major headache that I can't seem to find a solution for but I'm sure there must be a workaround and I would really be grateful of any help. I'm currently building a web site for a small club I belong to and one of the features I would like to include is the ability to allow users to upload image files. unfortunately the servers web root www folder only allows READ and EXECUTE permissions, which makes it...
7
3186
by: pbd22 | last post by:
hi. i am having probs understanding how to grab a file being uploaded from a remote client. i am using hidden input fields for upload such as: <input id="my_file_element" type="file" name="file_1" size=46 /><input type=submit /> so, after adding a few files, the input fields look like this:
9
20894
by: 8anos | last post by:
Hello, I am new at the community and newbie at programming :) As you may know rapidshare provides a perl script for linux, to upload files at their servers. You can find the original scripts at rapidshare news : http://images.rapidshare.com/software/rsapi.pl If you test it you will see that you can upload one file at time. I try to modify it in that way that script can read a text file with the names of the files i want to...
9
3892
by: Steve Poe | last post by:
I work for an animal hospital trying to use PHP to store an animal's dental x-rays to a file server. I can browse for the xray on the local desktop computer then click "Upload Image". This works fine. The doctors want fewer steps to follow. So, it was asked if I can configure the browser to load/submit the image 'xray.tif' each time they click "Upload Image" instead of the doctor/animal technician having to look for for dental x-ray...
21
34413
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most obvious of which is the sharing of files. For example, you upload images to a server to share them with other people over the Internet. Perl comes ready equipped for uploading files via the CGI.pm module, which has long been a core module and allows users...
1
3952
by: kksandeep | last post by:
i am using this three files to uplod file. i got this file from net but i think these have some error. i am new to this field plz help the script i found is some helpful but not too that i need my objective is this that when i uplod a file it should be desply on same page with ajax uplod after when i refresh page this should be not remains longer and on clicking other image its replase previous image plz help how i can do this the...
5
3288
by: camphor | last post by:
hi, I have found an upload script in hotscripts and have implemented it into the website, I followed the installation steps to 'give write permissions to php on the upload folder (which is _uploadedfiles_xxxx) (php must be allowed to move uploaded files to this folder' - uploadedfiles_xxxx. I typed <?php chmod ('_uploadedfiles_xxxx',640); ?> into notepad and saved it as php in the uploaded_xxxx folder, when I went to test it, the error...
24
7713
by: owz2008 | last post by:
This has probably been covered before but could not find a similar thread. Basically I have created a form which can be viewed at www.icomworks.co.uk/canvaspayform.html I want to submit the form along with the file so that they are both placed on my server... I have created a folder on my server in my public_html called myscripts and have saved my upload.cgi script into that folder. my form points to that script but when I fill in the...
0
8680
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9169
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9030
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6528
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.