Page 1 of 1

simple upload script

Posted: Wed Aug 13, 2008 7:32 am
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.

Re: simple upload script

Posted: Wed Aug 13, 2008 7:46 am
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

Re: simple upload script

Posted: Wed Aug 13, 2008 9:21 am
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?