simple upload script

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
private_click
Forum Newbie
Posts: 2
Joined: Wed Aug 13, 2008 7:18 am

simple upload script

Post by private_click »

hello.
i am having some problems with my upload script and i don't really know what's wrong.
i am running apache2.2 with php 5.2.6 with mysql5 on windows xp.
i am currently working on a youtube clone script.everything works great, except the uploading the file to the server.
i will give u the code for index.php

Code: Select all

 
<?php
session_start();
if(!isset($_POST['upload'])) {
    echo '
        <form name="upload" enctype="multipart/form-data" method="POST" action="'.$_SERVER['REQUEST_URI'].'">
        <input type="file" name="file" size="13" value="">
        <br /><input type="submit" name="upload" value="Upload">
        </form>
    ';
} 
else 
{
    $yourdomain = 'mydomain.com'; //it's set correctly in script, just removed for devnetwork
    $uploaddir = 'upload/raw/';
    $filename = $_FILES['file']['name'];
    $filesize = $_FILES['file']['size'];
    $tmpname_file = $_FILES['file']['tmp_name'];
    move_uploaded_file($tmpname_file, "$uploaddir$filename");
    echo "Successful.<br /><b>URL: </b><textarea rows='1' cols='13'>".$yourdomain.$uploaddir.$filename."</textarea>";
}
?> 
 
the thing is it works with .jpg files and mp3 (as i tested) but when i try to upload a .mpg it just refresh the page and it doesn't upload the file.
the limit in php.ini for uploading files is set to 500M, the .mpg is 50M, and in phpinfo() it display that the limit is set to 500M, so i guess no problem there.
pls help.thx.
User avatar
lukewilkins
Forum Commoner
Posts: 55
Joined: Tue Aug 12, 2008 2:42 pm

Re: simple upload script

Post by lukewilkins »

Hmmm, that is a little strange.

Code: Select all

<input type="hidden" name="MAX_FILE_SIZE" value="15728640" />
Add that inside your <form></form> tags and edit the value to whatever you need it to be (in bytes). It is 15MB as is.

Let me know if that works or not for you.

Luke
private_click
Forum Newbie
Posts: 2
Joined: Wed Aug 13, 2008 7:18 am

Re: simple upload script

Post by private_click »

i succesfully uploaded a 1.6Mb .mpg and converted it to .flv using my script.
still, when i try to upload bigger .mpg files (like 48Mb and 50 Mb) it just reload the script so i guess the problem is about the file size.
i also updated the following directives in php.ini:

Code: Select all

max_execution_time = 300000     ; Maximum execution time of each script, in seconds
max_input_time = 600000000000000000 ; Maximum amount of time each script may spend parsing request data
memory_limit = 900M      ; Maximum amount of memory a script may consume (8MB)
i guess the values i wrote are big enough.the values are also updated in phpinfo();
any ideas?
Post Reply