0

hi all,
i had a page where we can upload files.so when i upload pdf,wmv,win files, they are not uploading. but the rest like txt,doc,jpeg are uploading fine.
so i need pdf,wmv,win files also upload. so can any one please...
here is my upload code.

<?php  
ob_start();
@session_start();
require_once ("check.php");
createsessions($username,$password,$userid,$projectid,$projectname,$filename,$size,$allocatedmemory,$answer,$usedmemory,$Remainingmemory,$result,$data3);
include 'connection.php'; 
$id=$_POST[f]; 
$filename=$_FILES['uploaded']['name']; 
$s=($_FILES['uploaded']['size']);
$a= round($s/1024,2); 
$size=round($s/1024,2)." kb";
$answer=$_SESSION[answer];
 $usedmemory=$_POST['usedmemory'];
 $allocatedmemory=$_POST['data1'];
  $remainingmemory=$_SESSION['data3']; 
  
  $query="select filename from files where filename='$filename' and projectname='$_SESSION[answer]'";
            mysql_error();  
            $result=mysql_query($query);
            $count=mysql_num_rows($result); 
            
  if($count=='0')
  {          
  if($a < $remainingmemory)
   {
   $sql="insert into files(filename,size,uploadedby,projectname) values ('$filename','$size','$_SESSION[username]','$_SESSION[answer]')";
   mysql_error();
   $result = mysql_query($sql);
   $dirname=$_SESSION[username];
   $sql2="select reportingto from users where username='$_SESSION[username]'";
   mysql_error();
   $result2 = mysql_query($sql2);
   if (mysql_num_rows($result2) > 0) 
   { 
        while($row = mysql_fetch_row($result2)) 
        { 
            $admin=$row[0];
        }
   }     
   $dir=$admin;
   $projectname=$_SESSION[answer];
        if(is_dir($dirname)) 
        {             
            $target = "$dir/$projectname/$dirname/";
            $target = $target . basename( $_FILES['uploaded']['name']);
            $ok=1; 
            if ($ok==0) 
            { 
                echo "Sorry your file was not uploaded"; 
            } 
            else 
            {    
                if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) 
                { 
                    echo "<strong style='color:green'>"."The file ". basename( $_FILES['uploaded']['name']). " has been uploaded"."</strong>";
                     
                }
                else 
                { 
                    echo " "; 
                }  
            }
        }
        else
        {
            $path="$dir//$projectname//$dirname";
            @mkdir($path,0777,true);
            $target = "$dir/$projectname/$dirname/";
            $target = $target . basename( $_FILES['uploaded']['name']);
            $ok=1; 
            if ($ok==0) 
            { 
                echo "Sorry your file was not uploaded"; 
            } 
            else 
            { 
                if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) 
                { 
                    echo "<strong style='color:green'>"."The file ". basename( $_FILES['uploaded']['name']). " has been uploaded"."</strong>";
                } 
                else 
                { 
                    echo " "; 
                }                 
            }
        }
   }
  else
   {
       echo "<strong style='color:#FF3333'>"."<left><h1>Insufficient Memory.</h1></left>"."</strong>";
  }
  }
  else
  {
       echo "<strong style='color:#FF3333'>"."<left><h1>File with this name exist.</h1></left>"."</strong>";
  } 
  echo "<left> <br> <input type='button' value='back' onClick='history.go(-1)'></left>";    
                 
 ?>
3
Contributors
16
Replies
17
Views
7 Years
Discussion Span
Last Post by json101
0

if upload a pdf file of size 326 KB then it is uploading but if i upload 2036 kb then it is not uploading.

0

Create a .htaccess file in the root folder of web server
Put the following code in the .htaccess file and save it.

php_value upload_max_filesize 20M
php_value post_max_size 20M
php_value max_execution_time 200
php_value max_input_time 200

Now you can upload of up-to 20MB

Edited by json101: n/a

0

Open notepad, paste the code in, click save with the name .htaccess
Upload it to your website root folder (www or public_html)

Test your upload thingy and see what happens.

0

ya i had done in that way but i didnt get that. I am unable to upload files with size more than 2 MB

0

On localhost? IIS, WAMP or the like?
On WAMP it's the rewrite module, on IIS - no clue.

Basically, that code should work online.

0

may i send u a private message of my php.ini . so can u modify the necessary changes init.

0

Change this in your php.ini

post_max_size = 16M
upload_max_filesize = 20M

Restart your PC/Server and you're set.

0

hey tats great man...!!! Thank u i got it. wat the thing is after these changes we should restart server or PC.
Thanks again..

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.