General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old June 24th, 2003, 05:45 PM
stc7outlaw stc7outlaw is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 13 stc7outlaw User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
multiple upload

I have this code and would like to be able to have multiple uploads at once. How could I make code that will have the ability to have an unlimited amount of file uploads and keep a description for each upload in the same row.
PHP Code:
<?php 

// store.php3 
// Example php script to demonstrate the storing of binary files into 
// an sql database. 
?> 

<HTML> 
<HEAD><TITLE>Store binary data into SQL Database</TITLE></HEAD> 
<BODY> 

<?php 
// code that will be executed if the form has been submitted: 

if ($submit) { 

    
// connect to the database 
    // (you may have to adjust the hostname,username or password) 

    
MYSQL_CONNECT("localhost","root","password"); 
    
mysql_select_db("binary_data"); 

    
$data addslashes(fread(fopen($form_data"r"), filesize($form_data))); 

    
$result=MYSQL_QUERY("INSERT INTO binary_data (description,bin_data,filename,filesize,filetype) "
        
"VALUES ('$form_description','$data','$form_data_name','$f  orm_data_size','$form_data_type')"); 

    
$idmysql_insert_id(); 
    print 
"<p>This file has the following Database ID: <b>$id</b>"

    
MYSQL_CLOSE(); 

} else { 

    
// else show the form to submit new data: 
?> 

    <form method="post" action="<?php echo $PHP_SELF?>" enctype="multipart/form-data"> 
    File Description:<br> 
    <input type="text" name="form_description"  size="40"> 
    <INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="1000000"> 
    <br>File to upload/store in database:<br> 
    <input type="file" name="form_data"  size="40"> 
    <p><input type="submit" name="submit" value="submit"> 
    </form> 

<?php 



?> 

</BODY> 
</HTML>



It must be a loop or something but I have no clue how to do it correctly. Please help me. Thank you.

-Steve

Reply With Quote
  #2  
Old June 25th, 2003, 02:58 AM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 7
Just make the file input an array:

Example Script:
PHP Code:
<pre>
<?
php

  
if ($_POST['check']) {
        
print_r($_POST);
  }

?>

<form name"test" method="post" action="filearray.php">

<input type="file" name="form_data[]"  size="40">   
<input type="file" name="form_data[]"  size="40">
<input type="file" name="form_data[]"  size="40">
          
<input type="submit" name="check" value="upload">

</form>
</pre> 
__________________
__________________________________________________ _
Wil Moore III, MCP | Integrations Specialist | Senior Consultant
Are You Listed...? | DigitallySmooth Inc.

Reply With Quote
  #3  
Old June 25th, 2003, 09:08 AM
stc7outlaw stc7outlaw is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 13 stc7outlaw User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
now, do you mean replace that with the
Code:
if ($submit) {

fuction?

Reply With Quote
  #4  
Old June 25th, 2003, 10:29 AM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 7
Yes, you want this executed only if the form is submitted.

Reply With Quote
  #5  
Old June 25th, 2003, 04:34 PM
stc7outlaw stc7outlaw is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 13 stc7outlaw User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
i cant seem to get that to work. Maybe i'll try another way or something, but this has been ticking me off lately. Stupid arrays.

Reply With Quote
  #6  
Old June 25th, 2003, 04:43 PM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 7
Don't get mad at the arrays... They are so powerful... you need to learn how to work them, don't let them work you.

Reply With Quote
  #7  
Old June 27th, 2003, 10:22 AM
devilFish devilFish is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 11 devilFish User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally posted by laidbak
you need to learn how to work them, don't let them work you.


Because arrays are powerful often means that they can be complicated to start off with. If you want to know more about arrays in general, try just messing around with them, and THEN try and get them working with the form. They can be very powerful if you learn how to take advantage of all of the functions that manilupate them.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > multiple upload


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT