SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
Thread: Uploading files?
-
May 23, 2004, 15:21 #1
- Join Date
- Jan 2004
- Location
- Denmark
- Posts
- 48
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Uploading files?
I am trying to upload several files but it dosnt work. Can anybody tell what i am doing wrong?
<FORM ACTION="upload.php" METHOD="POST" encrypt="multipart/form-data">
<tr><td>Fil 1/td><td><input name="thefile[]" type="file"></td></tr>
<tr><td>Fil 2/td><td><input name="thefile[]" type="file"></td></tr>
<tr><td>Fil 3/td><td><input name="thefile[]" type="file"></td></tr>
<tr><td>Fil 4/td><td><input name="thefile[]" type="file"></td></tr>
<tr><td>Fil 5/td><td><input name="thefile[]" type="file"></td></tr>
<tr><td>Fil 6/td><td><input name="thefile[]" type="file"></td></tr>
<tr><td>Fil 7/td><td><input name="thefile[]" type="file"></td></tr>
<tr><td>Fil 8/td><td><input name="thefile[]" type="file"></td></tr>
<tr><td>Fil 9/td><td><input name="thefile[]" type="file"></td></tr>
<tr><td>Fil 10/td><td><input name="thefile[]" type="file"></td></tr>
<tr><td>Fil 11/td><td><input name="thefile[]" type="file"></td></tr>
<tr><td>Fil 12/td><td><input name="thefile[]" type="file"></td></tr>
<tr><td><td colspan="2"><input type="submit" value="UPLOAD"></td></tr></FORM>
PHP Code:
// upload.php
$thefile = $_POST['thefile'];
for ($i=0; $i<count($thefile); $i++) {
$tmp = $_FILES['thefile']['tmp_name'][$i];
$filename = time() .jpg;
$file = "c:/data/voice/arkiv/" . $filename;
if (is_uploaded_file($tmp) AND copy($tmp, $file)) {
}
}
-
May 23, 2004, 15:50 #2
- Join Date
- Mar 2004
- Location
- New Jersey
- Posts
- 140
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Change encrypt="multipart/form-data" to enctype="multipart/form-data".
-
May 23, 2004, 15:54 #3
- Join Date
- Feb 2004
- Location
- Scottsdale, Arizona
- Posts
- 909
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Also change
PHP Code:$filename = time() .jpg;
PHP Code:$filename = time() '.jpg';
-
May 24, 2004, 02:08 #4
- Join Date
- Jan 2004
- Location
- Denmark
- Posts
- 48
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
The strange thing is that when i use enctype instead of encrypt it dosnīt count the arrays thefile ?
-
May 24, 2004, 02:20 #5
Consider using a variable for the path, makes it easier if you ever want to use the script elsewhere.
$file = "c:/data/voice/arkiv/" . $filename;Laws are like sausages. You have much more respect for them if you haven't actually seen how they're made.
http://www.webamoeba.co.uk
-
May 24, 2004, 12:40 #6
- Join Date
- Jan 2004
- Location
- Denmark
- Posts
- 48
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I found the answer to my question. i used $thefile = $_POST['thefile']; instead of
$thefile = $_FILES['thefile'];
Bookmarks