1

I have a script in php and i'm trying to upload audio files with it, and later i want to use it to upload video files as well but it doesn't let me do that. I changed upload_max_filesize = 2000M just to be sure but it's still not working.

here is my script:

><?php

>if (isset($_FILES["file"]))

>{

>   echo "<p>"."Upload: " . $_FILES["file"]["name"] ."</p>". "<br>";

>   echo "Type: " . $_FILES["file"]["type"] . "<br>";

>   echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";

>   echo "Stored in: " . $_FILES["file"]["tmp_name"];


>   $uploaddir = '../audio/';

>   $file = basename($_FILES['file']['name']);

>   $uploadfile = $uploaddir . $file;
>   
>   print_r($_FILES);
>
>   if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) 

>   {

>       echo "it's mine!";

>   }

>   else

>   {

>       echo "sh*t!";

>   }

>}

>?>

what can i do? I also checked juploade but i can't find any documentation on how to use it.

also, if i try to upload txt or other small files it works.

Spluf
  • 810
  • 1
  • 11
  • 26
  • i tried with >echo $_FILES["file"]["error"] but it didn't show anything so i wrote that to see if it works – Spluf Feb 12 '14 at 18:38
  • i kept trying with different files, it seems that i can't upload anything over 2Mb. – Spluf Feb 12 '14 at 18:52

1 Answers1

4

pls replcae this :

if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)
with : 
if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile.$_FILES["file"]["name"])) 

try changing this on php.ini

memory_limit = 99M
max_execution_time = 300
upload_max_filesize = 20M
post_max_size = 24M
ImadOS
  • 425
  • 3
  • 14
  • still nothing. This is what it shows me: Type: Size: 0 kB Stored in: Array ( [file] => Array ( [name] => 07 - Rankin Dread - Fattie Boom Boom.mp3 [type] => [tmp_name] => [error] => 1 [size] => 0 ) ) 1 – Spluf Feb 12 '14 at 18:46
  • ok in that case you have to change all this in php.ini to allow upload over 2Mo memory_limit = 99M max_execution_time = 300 upload_max_filesize = 20M post_max_size = 24M – ImadOS Feb 12 '14 at 18:54
  • ok, this is strange. Apparently i changed the setings from the wrong place... (wamp/bin/php/etc...)... but now i opened php.ini directly from the taskbar -> wamp and there were still to the default (2m, so on) so now, after i changed the settings there as well it works, thank you for your help :) – Spluf Feb 12 '14 at 19:11
  • @Spluf , you welcome , can you give the answer a vote up and right answer pls :) – ImadOS Feb 12 '14 at 19:28
  • i don't have rep, i already tried, how can i make reputation? :) – Spluf Feb 12 '14 at 20:07
  • ok not a problem ,thank you , you can make reputation by answering others and post important questions . – ImadOS Feb 12 '14 at 21:02
  • i gave you a voteup for you question , you will get some reputation points for this voteup ;) – ImadOS Feb 12 '14 at 21:03
  • thanks man, i won't forget this :)... good luck with everything! – Spluf Feb 14 '14 at 23:37