Link upload files to a MySQL database and then link files

Ask about a PHP problem here.

Link upload files to a MySQL database and then link files

Postby chris122380 » Tue Aug 07, 2012 9:15 pm

I would like to upload files and assign them to a database field and then query that database with links to those uploaded files. This is as much as I have programmed and now lost. Any help getting this to work would be great. (Thanks to all those who have helped me so far and to YouTube for helping me find sample videos.) I visually have the drop down menu and the upload on the same page. I have the index.php file that has the drop down in php and the form in html. I also have a upload.php wich I would like to have manage the form uploading the file to documents folder and the file name uploaded to the operation_manuals table field manual_name and the spec next to it in the table being the spec chosen from the drop down.

Index.php :
Syntax: [ Download ] [ Hide ]
Using PHP Syntax Highlighting
  1. <?php
  2. // index.php
  3. // create a droptdown menu and upload form
  4. // connect upload file name to the dropdown menu field.
  5. // Chris Anthony MA 8/6/2012
  6. //
  7. // Connect to MySQL Database
  8. include('../../conect.php');
  9.  
  10. //dropdown box of spec see
  11. // http://www.learnphp.co/creating-an-html-select-box-from-a-mysql-results-array-using-php/
  12. // for example code.
  13. // query the database for the spec.
  14. $sql = "SELECT * FROM `canthony`.`spec` AS `spec`";
  15.    
  16.         $query = mysql_query($sql);
  17.      while ( $results[] = mysql_fetch_object ( $query ) );
  18.      array_pop ( $results );
  19. // print_r_html($results);
  20.  
  21. ?>
  22.  
  23. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  24.     "http://www.w3.org/TR/html4/loose.dtd">
  25. <html lang="en">
  26. <head>
  27.     <title>Uploading files</title>
  28. </head>
  29. <body>
  30.         <h1>Uploading files</h1>
  31.     <hr>    <!-- Makes a Horizontal line accross the page -->
  32. <!-- Form for selecting spec and file to upload to the operation_manuals table
  33. spec to spec and upload to manual_name field.
  34. -->
  35.  <form action='upload.php' method='post' enctype='multipart/form-data'>
  36.        
  37.         File: <input type='file' name='upload'> <!-- Uploads file -->
  38.      
  39.         <!-- Drop down menu -->        
  40.         <select name="spec_drop">
  41.          <?php foreach ( $results as $option ) : ?>
  42.               <option value="<?php echo $option->spec; ?>"><?php echo $option->spec ; ?></option>
  43.          <?php endforeach; ?>
  44.          </select>
  45.          <input type='submit' name='submit' value='Upload File Now'>     <!-- Submit button -->
  46.  </form>
  47.  
  48. </body>
  49. </html>
Parsed in 0.041 seconds, using GeSHi 1.0.8.10


upload.php :
Syntax: [ Download ] [ Hide ]
Using PHP Syntax Highlighting
  1. <?php
  2. //upload.php
  3. // Takes file from index.html form and adds the upload date to the file
  4. // and places the file into the documents folder.
  5. // The documents folder must already exist.
  6. // Chris Anthony MA 8/2/2012
  7. //
  8. //
  9.  
  10. // Connect to MySQL Database
  11. include('../conect.php');
  12.  
  13. // Pull upload form index.html
  14. if($_POST['submit']){
  15.    
  16.     // Assign uploaded file information to Variables.
  17.     // Upload listed in this array is the same name as the input name in the form.
  18.     $name = $_FILES['upload']['name'];
  19.     $temp = $_FILES['upload']['tmp_name'];
  20.     $type = $_FILES['upload']['type'];
  21.     $size = $_FILES['upload']['size'];
  22.    
  23.  // Validate variables for error checking   echo "$name<br />$temp<br />$type<br />$size";
  24.    
  25.     // File types allowed to be uploaded (.pdf, doc, .docx, .xls, .xtsx, .jpg, and .jpeg)
  26.     if(($type == 'application/pdf') || ($type == 'application/msword') || ($type == 'application/vnd.openxmlformats-officedocument.wordprocessingml.document') || ($type == 'application/vnd.ms-excel') || ($type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') || ($type == 'image/jpg') || ($type == 'image/jpeg')){
  27.    
  28.    
  29.     // Limit file size to 300mb $size is the max file size alloud.
  30.     if($size <= 314572800){
  31.        
  32.         // echo "The file: $name size is $size";
  33.        
  34.         // Todays date mm_dd_yyyy_
  35.         $todaysDate = date("m_j_Y_");
  36.        
  37.         //add the date to the begining of the file name.
  38.         $newfile = $todaysDate.$name;
  39.                
  40.                 // echo $newfile;
  41.        
  42.         // Move file from memory to documents folder located in the same location as this file.                
  43.         move_uploaded_file($temp,"documents/$newfile");
  44.      
  45.        // echo "<img src='$newfile'>";
  46.       // Places the upload as a link into a variable
  47.        $link = "<a href='documents/$newfile'>$newfile</a>";
  48.        
  49.        // Make Link or way to test $link variable
  50.        echo $link;
  51.        
  52.         // Place write to MySQL. Write $newfile to a database field.
  53.         // query database to pull spec from Chris Anthony
  54.             $sql = "SELECT `contacts`.`first_name` AS `Chris`, `contacts`.`last_name` AS `Anthony`, `spec`.`spec` FROM `canthony`.`projectcontact` AS `projectcontact`, `canthony`.`contacts` AS `contacts`, `canthony`.`project_spec` AS `project_spec`, `canthony`.`spec` AS `spec`, `canthony`.`project` AS `project` WHERE `projectcontact`.`Contacts_ID` = `contacts`.`ID` AND `project_spec`.`spec` = `spec`.`spec` AND `project_spec`.`Project_ID` = `project`.`Project_ID` AND `projectcontact`.`Project_ID` = `project`.`Project_ID`";
  55. $result = mysql_query($sql);
  56.        
  57.        
  58.        
  59.    
  60.     }else{
  61.        
  62.         // File is bigger the 300mb warning
  63.         echo "The file: $name is to big....<br />The size is $size and need to be less than 300mb";
  64.        
  65.     }
  66.        
  67.     }else{
  68.        
  69.         // File type not allowed warning
  70.         echo "This type $type is not allowed";
  71.     }
  72.        
  73. }else{
  74.    
  75.     // forces back to index.html when trying to open upload.php from browser URL
  76.     header("Location: index.html");
  77.    
  78. }
  79.  
  80. ?>
Parsed in 0.047 seconds, using GeSHi 1.0.8.10
Local Server: XAMMP 1.8.0, Windows 7 64bit
Local PHP: 5.4.4
Local Apache: 2.4.2
Local MySQL: 14.14 Distrib 5.5.25a, for Win32 (x86)
PHP/HTML Editor: Komodo Edit, version 7.1.0
chris122380
 
Posts: 9
Joined: Thu Jul 26, 2012 3:17 pm

Re: Link upload files to a MySQL database and then link file

Postby Temor » Tue Aug 07, 2012 10:11 pm

Well, you would have to create an INSERT query in your upload.php. The way I usually do this is to link the file by it's ID in the table.
Syntax: [ Download ] [ Hide ]
Using PHP Syntax Highlighting
  1. $sql = "INSERT INTO `file` (`file_name`) VALUES ('{$_FILES['upload']['name']}' ";
  2. mysql_query($sql);
Parsed in 0.034 seconds, using GeSHi 1.0.8.10


and then I would fetch the item by the ID as stated previously.

Syntax: [ Download ] [ Hide ]
Using PHP Syntax Highlighting
  1. $sql = "SELECT `file_name` FROM `file` WHERE `id` = {$id}
  2. $result = mysql_query($sql);
Parsed in 0.034 seconds, using GeSHi 1.0.8.10
User avatar
Temor
 
Posts: 1161
Joined: Thu May 05, 2011 8:04 pm

Re: Link upload files to a MySQL database and then link file

Postby chris122380 » Wed Aug 08, 2012 3:16 pm

My table (operation_manuals) has two fields spec (Spec is a foreign key that links to a table with the list of spec numbers and there descriptions) and manual_name. The drop down menu pulls the spec number from the spec table. The file name needs to be linked with the spec number as I may need to reference the file by name or by spec number.

I have added the fallowing code to the upload.php after my link is made (Link was for testing purposes).
Syntax: [ Download ] [ Hide ]
Using PHP Syntax Highlighting
  1.    $sql = "INSERT INTO `manual_name` (`$newfile`) VALUES ('{$_FILES['upload']['name']}' ";
  2. mysql_query($sql);
Parsed in 0.034 seconds, using GeSHi 1.0.8.10
I then get the fallowing error:
( ! ) SCREAM: Error suppression ignored for
( ! ) Warning: include(../conect.php): failed to open stream: No such file or directory in C:\xampp\htdocs\manualsaccess\test_iFrame\File_upload\new\upload.php on line 11
and
( ! ) SCREAM: Error suppression ignored for
( ! ) Warning: include(): Failed opening '../conect.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\manualsaccess\test_iFrame\File_upload\new\upload.php on line 11


Line 11 is my include('../conect.php') to connect to the database. I know the connection is working so unsure why the error.

I have also tried
Syntax: [ Download ] [ Hide ]
Using PHP Syntax Highlighting
  1. mysql_query("INSERT INTO manual_name VALUES('','','$option','$newfile')")
Parsed in 0.039 seconds, using GeSHi 1.0.8.10
same two errors and a third error now
( ! ) SCREAM: Error suppression ignored for
( ! ) Notice: Undefined variable: option in C:\xampp\htdocs\manualsaccess\test_iFrame\File_upload\new\upload.php on line 59
line 59 is the INSERT query line. Same errors when trying this code instead.
Syntax: [ Download ] [ Hide ]
Using PHP Syntax Highlighting
  1.   mysql_query("INSERT INTO manual_name  (manual_ID, manual_status, spec, manual_name) VALUES('','','$option','$newfile')");
Parsed in 0.041 seconds, using GeSHi 1.0.8.10
Local Server: XAMMP 1.8.0, Windows 7 64bit
Local PHP: 5.4.4
Local Apache: 2.4.2
Local MySQL: 14.14 Distrib 5.5.25a, for Win32 (x86)
PHP/HTML Editor: Komodo Edit, version 7.1.0
chris122380
 
Posts: 9
Joined: Thu Jul 26, 2012 3:17 pm

Re: Link upload files to a MySQL database and then link file

Postby chris122380 » Wed Aug 08, 2012 9:51 pm

Temor wrote:Well, you would have to create an INSERT query in your upload.php. The way I usually do this is to link the file by it's ID in the table.


I have added
Syntax: [ Download ] [ Hide ]
Using PHP Syntax Highlighting
  1.      $option = $_POST['spec_drop'];
  2.        
  3.        mysql_query("INSERT INTO operation_manuals (manual_ID, manual_status, spec, manual_name) VALUES('','','$option','$newfile')");
Parsed in 0.041 seconds, using GeSHi 1.0.8.10
I have no errors and seems to run correctly but nothing posts to the database. is there a way to error check the INSERT INTO MySQL to be sure there are no errors when trying to INSERT to the database?

I have also tried placing my INSERT before the file is moved (Line 38 in the upload.php example below) to the folder and still didn't post anything to the database).

Updated index.php
Syntax: [ Download ] [ Hide ]
Using PHP Syntax Highlighting
  1. <?php
  2. // index.php
  3. // create a droptdown menu and upload form
  4. // connect upload file name to the dropdown menu field.
  5. // Chris Anthony MA 8/6/2012
  6. //
  7. // Connect to MySQL Database
  8. include('../../conect.php');
  9.  
  10. //dropdown box of spec see
  11. // http://www.learnphp.co/creating-an-html-select-box-from-a-mysql-results-array-using-php/
  12. // for example code.
  13. // query the database for the spec.
  14.  $sql = "SELECT * FROM `canthony`.`spec` AS `spec`";
  15.    
  16.         $query = mysql_query($sql);
  17.      while ( $results[] = mysql_fetch_object ( $query ) );
  18.      array_pop ( $results );
  19. // print_r_html($results);
  20.  
  21. ?>
  22.  
  23. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  24.     "http://www.w3.org/TR/html4/loose.dtd">
  25. <html lang="en">
  26. <head>
  27.     <title>Uploading files</title>
  28. </head>
  29. <body>
  30.         <h1>Uploading files</h1>
  31.     <hr>    <!-- Makes a Horizontal line accross the page -->
  32. <!-- Form for selecting spec and file to upload to the operation_manuals table
  33. spec to spec and upload to manual_name field.
  34. -->
  35.  <form action='upload.php' method='post' enctype='multipart/form-data'>
  36.        
  37.         File: <input type='file' name='upload'> <!-- Uploads file -->
  38.      
  39.         <!-- Drop down menu -->        
  40.         <select name="spec_drop">
  41.          <?php foreach ( $results as $option ) : ?>
  42.               <option value="<?php echo $option->spec; ?>"><?php echo $option->spec ; ?></option>
  43.          <?php endforeach; ?>
  44.          </select>
  45.          <input type='submit' name='submit' value='Upload File Now'>     <!-- Submit button -->
  46.  </form>
  47.  
  48. </body>
  49. </html>
  50.  
  51.  
Parsed in 0.046 seconds, using GeSHi 1.0.8.10


Updated upload.php
Syntax: [ Download ] [ Hide ]
Using PHP Syntax Highlighting
  1. <?php
  2. //upload.php
  3. // Takes file from index.html form and adds the upload date to the file
  4. // and places the file into the documents folder.
  5. // The documents folder must already exist.
  6. // Chris Anthony MA 8/2/2012
  7. //
  8. //
  9. // Connect to MySQL Database
  10. // include('../conect.php');
  11.  
  12. // Pull upload form index.html
  13. if($_POST['submit']){
  14.    
  15.     // Assign uploaded file information to Variables.
  16.     // Upload listed in this array is the same name as the input name in the form.
  17.     $name = $_FILES['upload']['name'];
  18.     $temp = $_FILES['upload']['tmp_name'];
  19.     $type = $_FILES['upload']['type'];
  20.     $size = $_FILES['upload']['size'];
  21.    
  22.  // Validate variables for error checking   echo "$name<br />$temp<br />$type<br />$size";
  23.    
  24.     // File types allowed to be uploaded (.pdf, doc, .docx, .xls, .xtsx, .jpg, and .jpeg)
  25.     if(($type == 'application/pdf') || ($type == 'application/msword') || ($type == 'application/vnd.openxmlformats-officedocument.wordprocessingml.document') || ($type == 'application/vnd.ms-excel') || ($type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') || ($type == 'image/jpg') || ($type == 'image/jpeg')){
  26.    
  27.    
  28.     // Limit file size to 300mb $size is the max file size alloud.
  29.     if($size <= 314572800){
  30.        
  31.         // echo "The file: $name size is $size";
  32.        
  33.         // Todays date mm_dd_yyyy_
  34.         $todaysDate = date("m_j_Y_");
  35.        
  36.         //add the date to the begining of the file name.
  37.         $newfile = $todaysDate.$name;
  38.                
  39.                 // echo $newfile;
  40.        
  41.         // Move file from memory to documents folder located in the same location as this file.                
  42.         move_uploaded_file($temp,"documents/$newfile");
  43.      
  44.        // echo "<img src='$newfile'>";
  45.       // Places the upload as a link into a variable
  46.        $link = "<a href='documents/$newfile'>$newfile</a>";
  47.        
  48.        // Make Link or way to test $link variable
  49.        echo $link;
  50.        
  51.         // Place write to MySQL. Write $newfile to a database field.
  52.         // query database to pull spec from Chris Anthony
  53.           /*  $sql = "SELECT `contacts`.`first_name` AS `Chris`, `contacts`.`last_name` AS `Anthony`, `spec`.`spec` FROM `canthony`.`projectcontact` AS `projectcontact`, `canthony`.`contacts` AS `contacts`, `canthony`.`project_spec` AS `project_spec`, `canthony`.`spec` AS `spec`, `canthony`.`project` AS `project` WHERE `projectcontact`.`Contacts_ID` = `contacts`.`ID` AND `project_spec`.`spec` = `spec`.`spec` AND `project_spec`.`Project_ID` = `project`.`Project_ID` AND `projectcontact`.`Project_ID` = `project`.`Project_ID`";
  54. $result = mysql_query($sql); */
  55.        
  56.        /* $sql = "INSERT INTO `manual_name` (`$newfile`) VALUES ('{$_FILES['upload']['name']}' ";
  57. mysql_query($sql); */
  58.        
  59.        $option = $_POST['spec_drop'];
  60.        
  61.        mysql_query("INSERT INTO operation_manuals (manual_ID, manual_status, spec, manual_name) VALUES('','','$option','$newfile')");
  62.        
  63.    
  64.     }else{
  65.        
  66.         // File is bigger the 300mb warning
  67.         echo "The file: $name is to big....<br />The size is $size and need to be less than 300mb";
  68.        
  69.     }
  70.        
  71.     }else{
  72.        
  73.         // File type not allowed warning
  74.         echo "This type $type is not allowed";
  75.     }
  76.        
  77. }else{
  78.    
  79.     // forces back to index.html when trying to open upload.php from browser URL
  80.     header("Location: index.html");
  81.    
  82. }
  83.  
  84. ?>
Parsed in 0.058 seconds, using GeSHi 1.0.8.10
Local Server: XAMMP 1.8.0, Windows 7 64bit
Local PHP: 5.4.4
Local Apache: 2.4.2
Local MySQL: 14.14 Distrib 5.5.25a, for Win32 (x86)
PHP/HTML Editor: Komodo Edit, version 7.1.0
chris122380
 
Posts: 9
Joined: Thu Jul 26, 2012 3:17 pm

Re: Link upload files to a MySQL database and then link file

Postby Temor » Thu Aug 09, 2012 2:24 am

Adding
Syntax: [ Download ] [ Hide ]
Using PHP Syntax Highlighting
  1. echo mysql_error();
Parsed in 0.042 seconds, using GeSHi 1.0.8.10
under a failing query will provide a more detailed error message.
This
Syntax: [ Download ] [ Hide ]
Using PHP Syntax Highlighting
  1. $sql = "INSERT INTO `manual_name` (`$newfile`) VALUES ('{$_FILES['upload']['name']}' ";
  2. mysql_query($sql);
Parsed in 0.043 seconds, using GeSHi 1.0.8.10

won't work seeing as $newfile is not a column. Change that to the column name which you want to populate with $_FILES['upload']['name'].

/edit;
I will take a closer look at this tomorrow. I'm to tired to think right now. If I haven't updated this post in say 15 hours, send me a PM and remind me, will you? :)
User avatar
Temor
 
Posts: 1161
Joined: Thu May 05, 2011 8:04 pm

Re: Link upload files to a MySQL database and then link file

Postby chris122380 » Thu Aug 09, 2012 4:30 pm

Thank you the
Syntax: [ Download ] [ Hide ]
Using PHP Syntax Highlighting
  1. echo mysql_error();
Parsed in 0.043 seconds, using GeSHi 1.0.8.10
helped me a lot in looking for the solution. My upload is now working correctly with a drop down menu.

Updated and working code.
index.php
Syntax: [ Download ] [ Hide ]
Using PHP Syntax Highlighting
  1. <?php
  2. // index.php
  3. // create a droptdown menu and upload form
  4. // connect upload file name to the dropdown menu field.
  5. // Chris Anthony MA 8/6/2012
  6. //
  7. // Connect to MySQL Database
  8. include('../../conect.php');
  9.  
  10. //dropdown box of spec see
  11. // http://www.learnphp.co/creating-an-html-select-box-from-a-mysql-results-array-using-php/
  12. // for example code.
  13. // query the database for the spec.
  14.  $sql = "SELECT * FROM `canthony`.`spec` AS `spec`";
  15.    
  16.         $query = mysql_query($sql);
  17.      while ( $results[] = mysql_fetch_object ( $query ) );
  18.      array_pop ( $results );
  19. // print_r_html($results);
  20.  
  21. ?>
  22.  
  23. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  24.     "http://www.w3.org/TR/html4/loose.dtd">
  25. <html lang="en">
  26. <head>
  27.     <title>Uploading files</title>
  28. </head>
  29. <body>
  30.         <h1>Uploading files</h1>
  31.     <hr>    <!-- Makes a Horizontal line accross the page -->
  32. <!-- Form for selecting spec and file to upload to the operation_manuals table
  33. spec to spec and upload to manual_name field.
  34. -->
  35.  <form action='upload.php' method='post' enctype='multipart/form-data'>
  36.        
  37.         File: <input type='file' name='upload'> <!-- Uploads file -->
  38.      
  39.         <!-- Drop down menu -->        
  40.         <select name="spec_drop">
  41.          <?php foreach ( $results as $option ) : ?>
  42.               <option value="<?php echo $option->spec; ?>"><?php echo $option->spec ; ?></option>
  43.          <?php endforeach; ?>
  44.          </select>
  45.          <input type='submit' name='submit' value='Upload File Now'>     <!-- Submit button -->
  46.  </form>
  47.  
  48. </body>
  49. </html>
Parsed in 0.048 seconds, using GeSHi 1.0.8.10


upload.php
Syntax: [ Download ] [ Hide ]
Using PHP Syntax Highlighting
  1. <?php
  2. //upload.php
  3. // Takes file from index.html form and adds the upload date to the file
  4. // and places the file into the documents folder.
  5. // The documents folder must already exist.
  6. // Chris Anthony MA 8/2/2012
  7. //
  8. //
  9. // Connect to MySQL Database
  10. // include('../conect.php');
  11.  
  12. // Pull upload form index.html
  13. if($_POST['submit']){
  14.    
  15.     // Assign uploaded file information to Variables.
  16.     // Upload listed in this array is the same name as the input name in the form.
  17.     $name = $_FILES['upload']['name'];
  18.     $temp = $_FILES['upload']['tmp_name'];
  19.     $type = $_FILES['upload']['type'];
  20.     $size = $_FILES['upload']['size'];
  21.    
  22.  // Validate variables for error checking   echo "$name<br />$temp<br />$type<br />$size";
  23.    
  24.     // File types allowed to be uploaded (.pdf, doc, .docx, .xls, .xtsx, .jpg, and .jpeg)
  25.     if(($type == 'application/pdf') || ($type == 'application/msword') || ($type == 'application/vnd.openxmlformats-officedocument.wordprocessingml.document') || ($type == 'application/vnd.ms-excel') || ($type == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') || ($type == 'image/jpg') || ($type == 'image/jpeg')){
  26.    
  27.    
  28.     // Limit file size to 300mb $size is the max file size alloud.
  29.     if($size <= 314572800){
  30.        
  31.         // echo "The file: $name size is $size";
  32.        
  33.         // Todays date mm_dd_yyyy_
  34.         $todaysDate = date("m_j_Y_");
  35.        
  36.         //add the date to the begining of the file name.
  37.         $newfile = $todaysDate.$name;
  38.                
  39.                 // echo $newfile;
  40.        
  41.         // Move file from memory to documents folder located in the same location as this file.                
  42.         move_uploaded_file($temp,"documents/$newfile");
  43.      
  44.        // echo "<img src='$newfile'>";
  45.       // Places the upload as a link into a variable
  46.        $link = "<a href='documents/$newfile'>$newfile</a>";
  47.        
  48.        // Make Link or way to test $link variable
  49.        echo $link;
  50.        
  51.         // Place write to MySQL. Write $newfile to a database field.
  52.         // query database to pull spec from Chris Anthony
  53.           /*  $sql = "SELECT `contacts`.`first_name` AS `Chris`, `contacts`.`last_name` AS `Anthony`, `spec`.`spec` FROM `canthony`.`projectcontact` AS `projectcontact`, `canthony`.`contacts` AS `contacts`, `canthony`.`project_spec` AS `project_spec`, `canthony`.`spec` AS `spec`, `canthony`.`project` AS `project` WHERE `projectcontact`.`Contacts_ID` = `contacts`.`ID` AND `project_spec`.`spec` = `spec`.`spec` AND `project_spec`.`Project_ID` = `project`.`Project_ID` AND `projectcontact`.`Project_ID` = `project`.`Project_ID`";
  54. $result = mysql_query($sql); */
  55.        
  56.        /* $sql = "INSERT INTO `manual_name` (`$newfile`) VALUES ('{$_FILES['upload']['name']}' ";
  57. mysql_query($sql); */
  58.        
  59.        include('../../conect.php');
  60.        
  61.        $option = $_POST['spec_drop'];
  62.        
  63.        mysql_query("INSERT INTO operation_manuals (manual_ID, manual_status, spec, manual_name) VALUES('','1','$option','$newfile')");
  64.        // echo mysql_error();
  65.    
  66.     }else{
  67.        
  68.         // File is bigger the 300mb warning
  69.         echo "The file: $name is to big....<br />The size is $size and need to be less than 300mb";
  70.        
  71.     }
  72.        
  73.     }else{
  74.        
  75.         // File type not allowed warning
  76.         echo "This type $type is not allowed";
  77.     }
  78.        
  79. }else{
  80.    
  81.     // forces back to index.html when trying to open upload.php from browser URL
  82.     header("Location: index.php");
  83.    
  84. }
  85.  
  86. ?>
Parsed in 0.058 seconds, using GeSHi 1.0.8.10
Local Server: XAMMP 1.8.0, Windows 7 64bit
Local PHP: 5.4.4
Local Apache: 2.4.2
Local MySQL: 14.14 Distrib 5.5.25a, for Win32 (x86)
PHP/HTML Editor: Komodo Edit, version 7.1.0
chris122380
 
Posts: 9
Joined: Thu Jul 26, 2012 3:17 pm


Return to PHP



Who is online

Users browsing this forum: No registered users and 2 guests

cron