473,407 Members | 2,546 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,407 software developers and data experts.

Why is this code for uploading files not really uploading files

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.     // Connect to the database
  3.     $dbLink = new mysqli('127.0.0.1', 'user', 'pwd', 'myTable');
  4.     if(mysqli_connect_errno()) {
  5.         die("MySQL connection failed: ". mysqli_connect_error());
  6.     }
  7.  
  8.     // Query for a list of all existing files
  9.     $sql = 'SELECT `id`, `name`, `mime`, `size`, `created` FROM `file`';
  10.     $result = $dbLink->query($sql);
  11.  
  12.     // Check if it was successfull
  13.     if($result) {
  14.         // Make sure there are some files in there
  15.         if($result->num_rows == 0) {
  16.             echo '<p>There are no files in the database</p>';
  17.         }
  18.         else {
  19.             // Print the top of a table
  20.             echo '<table width="100%">
  21.                     <tr>
  22.                         <td><b>Name</b></td>
  23.                         <td><b>Mime</b></td>
  24.                         <td><b>Size (bytes)</b></td>
  25.                         <td><b>Created</b></td>
  26.                         <td><b>&nbsp;</b></td>
  27.                     </tr>';
  28.  
  29.             // Print each file
  30.             while($row = $result->fetch_assoc()) {
  31.                 echo "
  32.                     <tr>
  33.                         <td>{$row['name']}</td>
  34.                         <td>{$row['mime']}</td>
  35.                         <td>{$row['size']}</td>
  36.                         <td>{$row['created']}</td>
  37.                         <td><a href='get_file.php?id={$row['id']}'>Download</a></td>
  38.                     </tr>";
  39.             }
  40.  
  41.             // Close table
  42.             echo '</table>';
  43.         }
  44.  
  45.         // Free the result
  46.         $result->free();
  47.     }
  48.     else
  49.     {
  50.         echo 'Error! SQL query failed:';
  51.         echo "<pre>{$dbLink->error}</pre>";
  52.     }
  53.  
  54.     // Close the mysql connection
  55.     $dbLink->close();
  56.     ?>
Mar 22 '12 #1
1 1144
Dormilich
8,658 Expert Mod 8TB
because this code is not supposed to upload files. check Atli's thread (PHP insights) for a full explanation of the code.
Mar 22 '12 #2

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

Similar topics

4
by: googlinggoogler | last post by:
Hiya, The title says it all really, but im a newbie to python sort of. I can read in files and write files no probs. But what I want to do is read in a couple of files and output them to one...
21
by: Hattuari | last post by:
I'm learning C++ after having spent several years in the computer industry doing both system administration and engineering. I've written code in Perl, Bash, Pascal, Ada, C, Mathematica (hundreds...
1
by: LenS | last post by:
If this is the wrong place to post this, please advise better place. Otherwise, I have created the following python program and it works. Running on XP. I think I am now at that stage of learning...
3
by: Catalin Porancea | last post by:
Can anybody tell me what is wrong with this code? I would really appreciate some help here. The data grid has 4 columns (0,1,2,3), and 1 is not visible. Whenever I click Edit, I get this error:...
2
by: Ric | last post by:
im new to asp.net. from what i understand, you have the aspx file (presentation), user-control(ascx file), code-behind(vb file) and components(compiled vb and dll files). the aspx file contains a...
2
by: Kausar | last post by:
Hello All, I want to know how to scan the files before uploading it to the server in ASP.NET 2.0 application. One work arround i thought is to allow to upload in some temporary folder then sacn...
3
by: mra | last post by:
Hi I Need Help For Uploading And Down Loading Files Using Internet Tansfer Control. When Assign The Name Of File In A Variable, It Does Not Execute The State Change Event. When I Give The File Name...
4
by: muthu | last post by:
Hi, User will upload only picture and pdf files. I have return a asp.net application for that,But thing is I need to restrict the user uploading corrupted or damaged files. Can anyone have any...
6
by: kudlatykot | last post by:
Hi Everyone, when I use streams there's always possibility to add data - so file grows, but is it possible to shrink file by just cutting it's tail ? I have to work with really big files (~2 GB) so...
0
by: Chris Rebert | last post by:
On Mon, Sep 15, 2008 at 10:30 AM, aditya shukla <adityashukla1983@gmail.comwrote: Unless your Python scripts are essentially just *really basic* shell scripts that happen to be written in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.