File upload

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kpraman
Forum Contributor
Posts: 172
Joined: Fri Oct 13, 2006 10:54 am

File upload

Post by kpraman »

I am trying to upload mpeg file which is 4 mb.

Code: Select all

copy($_FILES['course_file']['tmp_name'],"on_line_course/".$_FILES['course_file']['name']);
files which are lesser than 1 mb are uploading successfully.

Is it because of size or the format. If it is because of size, how to upload large files?
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

First of all, take a look at: move_uploaded_file()
As to the problem, check the value of upload_max_filesize in your php.ini - the default is 2MB.
kpraman
Forum Contributor
Posts: 172
Joined: Fri Oct 13, 2006 10:54 am

Post by kpraman »

I have changed the code to

Code: Select all

move_uploaded_file($_FILES['course_file']['tmp_name'],'on_line_course/'.$_FILES['course_file']['name']);
How to increase the default size in code?
In the site link you have given says, even the memory size has to be increased, how to do that?
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

If you are on Apache, try to use .htaccess file to do that.
kpraman
Forum Contributor
Posts: 172
Joined: Fri Oct 13, 2006 10:54 am

Post by kpraman »

Online server is not with me. How to alter through code?
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

kpraman wrote:Online server is not with me.
What do you mean by that? That you can't change the server configuration?
I didn't tell you to change anything like that, just place an .htaccess file in the root.
Post Reply