473,394 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Upload pdf,wmv,win

18
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.

Expand|Select|Wrap|Line Numbers
  1. <?php  
  2. ob_start();
  3. @session_start();
  4. require_once ("check.php");
  5. createsessions($username,$password,$userid,$projectid,$projectname,$filename,$size,$allocatedmemory,$answer,$usedmemory,$Remainingmemory,$result,$data3);
  6. include 'connection.php'; 
  7. $id=$_POST[f]; 
  8. $filename=$_FILES['uploaded']['name']; 
  9. $s=($_FILES['uploaded']['size']);
  10. $a= round($s/1024,2); 
  11. $size=round($s/1024,2)." kb";
  12. $answer=$_SESSION[answer];
  13.  $usedmemory=$_POST['usedmemory'];
  14.  $allocatedmemory=$_POST['data1'];
  15.   $remainingmemory=$_SESSION['data3']; 
  16.  
  17.   $query="select filename from files where filename='$filename' and projectname='$_SESSION[answer]'";
  18.             mysql_error();  
  19.             $result=mysql_query($query);
  20.             $count=mysql_num_rows($result); 
  21.  
  22.   if($count=='0')
  23.   {          
  24.   if($a < $remainingmemory)
  25.    {
  26.    $sql="insert into files(filename,size,uploadedby,projectname) values ('$filename','$size','$_SESSION[username]','$_SESSION[answer]')";
  27.    mysql_error();
  28.    $result = mysql_query($sql);
  29.    $dirname=$_SESSION[username];
  30.    $sql2="select reportingto from users where username='$_SESSION[username]'";
  31.    mysql_error();
  32.    $result2 = mysql_query($sql2);
  33.    if (mysql_num_rows($result2) > 0) 
  34.    { 
  35.         while($row = mysql_fetch_row($result2)) 
  36.         { 
  37.             $admin=$row[0];
  38.         }
  39.    }     
  40.    $dir=$admin;
  41.    $projectname=$_SESSION[answer];
  42.         if(is_dir($dirname)) 
  43.         {             
  44.             $target = "$dir/$projectname/$dirname/";
  45.             $target = $target . basename( $_FILES['uploaded']['name']);
  46.             $ok=1; 
  47.             if ($ok==0) 
  48.             { 
  49.                 echo "Sorry your file was not uploaded"; 
  50.             } 
  51.             else 
  52.             {    
  53.                 if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) 
  54.                 { 
  55.                     echo "<strong style='color:green'>"."The file ". basename( $_FILES['uploaded']['name']). " has been uploaded"."</strong>";
  56.  
  57.                 }
  58.                 else 
  59.                 { 
  60.                     echo " "; 
  61.                 }  
  62.             }
  63.         }
  64.         else
  65.         {
  66.             $path="$dir//$projectname//$dirname";
  67.             @mkdir($path,0777,true);
  68.             $target = "$dir/$projectname/$dirname/";
  69.             $target = $target . basename( $_FILES['uploaded']['name']);
  70.             $ok=1; 
  71.             if ($ok==0) 
  72.             { 
  73.                 echo "Sorry your file was not uploaded"; 
  74.             } 
  75.             else 
  76.             { 
  77.                 if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) 
  78.                 { 
  79.                     echo "<strong style='color:green'>"."The file ". basename( $_FILES['uploaded']['name']). " has been uploaded"."</strong>";
  80.                 } 
  81.                 else 
  82.                 { 
  83.                     echo " "; 
  84.                 }                 
  85.             }
  86.         }
  87.    }
  88.   else
  89.    {
  90.        echo "<strong style='color:#FF3333'>"."<left><h1>Insufficient Memory.</h1></left>"."</strong>";
  91.   }
  92.   }
  93.   else
  94.   {
  95.        echo "<strong style='color:#FF3333'>"."<left><h1>File with this name exist.</h1></left>"."</strong>";
  96.   } 
  97.   echo "<left> <br> <input type='button' value='back' onClick='history.go(-1)'></left>";    
  98.  
  99.  ?>
Jun 3 '10 #1
1 1375
dlite922
1,584 Expert 1GB
I don't know what error you're getting but your PHP code is horrible, it's hacked together like someone took a code and modified the heck out of it:

here's one example:

Expand|Select|Wrap|Line Numbers
  1. $ok=1; 
  2. if ($ok==0) 
  3.  
What's the point of that if statement if it's always going to fail.

On related to your OP, I don't see anywhere in the code where the file time is regulated. Whatever is not letting you upload, I don't see it in your code posted above.

Good luck,



Dan
Jun 4 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a...
2
by: Sean Dotson | last post by:
I have a form that passes variables to an asp file and then uploads a file. For some reason the request.form is not getting the info from the form. It's returning blanks. Any insight would be...
0
by: SEMIH DEMIR | last post by:
Sitelerden birinde verilen yabancı kaynakli bir scriptti duzenledim yanlız birseyin içinden bir turlu cıkamadım işin aslı ilk defa persistin upload componentini kullanacam yanlız suanki haliyle...
1
by: Alex | last post by:
I am having issues with a script to upload files from a client to a webserver. The problem is not with the actual upload but with where it uploads. The whole process is supposed to create a...
9
by: Wayne Smith | last post by:
I've come up against a major headache that I can't seem to find a solution for but I'm sure there must be a workaround and I would really be grateful of any help. I'm currently building a web...
7
by: pbd22 | last post by:
hi. i am having probs understanding how to grab a file being uploaded from a remote client. i am using hidden input fields for upload such as: <input id="my_file_element" type="file"...
9
by: 8anos | last post by:
Hello, I am new at the community and newbie at programming :) As you may know rapidshare provides a perl script for linux, to upload files at their servers. You can find the original scripts at...
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
2
by: hotflash | last post by:
Hi All, I found the best pure ASP code to upload a file to either server and/or MS Access Database. It works fine for me however, there is one thing that I don't like and have tried to fix but...
1
by: chennaibala | last post by:
can any one send me mutiple image upload program and save the file name with extension in mysql table.we must cheak uploaded file type like bmp or any image file while uploading. i develop...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.