Forum Moderators: coopster

Message Too Old, No Replies

Photo Upload

         

outdoorxtreme1

2:53 pm on Nov 22, 2005 (gmt 0)

10+ Year Member



Am I able to modify this code so that I can upload multiple photos to MySQL?

<title>Simple file upload script</title>
</head>
<body>
<?php
if ($_REQUEST[completed] == 1) {
$source = "trip_log/pics";
move_uploaded_file($_FILES['filename']['tmp_name'],
"../$source/".$_FILES['filename']['name']);
// Following code to fix line ends
if (! eregi ('(gif¦jpg¦pdf)$',$_FILES['filename']['name'])) {
$fi = file("../$source/".$_FILES['filename']['name']);
$fi2 = fopen("../$source/".$_FILES['filename']['name'],"w");
foreach ($fi as $lne) {
$n = rtrim ($lne);
fputs ($fi2,"$n\n");
}
}
//
?>
Your file has been uploaded.
<?php } else {?>
<form enctype=multipart/form-data method=post>
<input type=hidden name=MAX_FILE_SIZE value=150000>
<input type=hidden name=completed value=1>
Choose file to send: <input type=file name=filename> and
<input type=submit></form><br>
<?php }?>
</body>
</html>

outdoorxtreme1

1:08 am on Nov 29, 2005 (gmt 0)

10+ Year Member



I deleted all of my picture files on my server and I am getting the same errors. I am not sure what I did before to get it to work but I think it has to do with the array. How do I get the Array strings to start out with 1 instead of 0

outdoorxtreme1

1:40 am on Nov 29, 2005 (gmt 0)

10+ Year Member



If I do this to MySQL:

INSERT INTO `pics` ( `pic_id` , `pic_name` , `descrip` )
VALUES (
'0', NULL , NULL
);

Then the php code works. Any idea what I did wrong in the first place?

outdoorxtreme1

1:04 pm on Nov 29, 2005 (gmt 0)

10+ Year Member



How do I upload a group of pictures to a new fold on each submit?
This 33 message thread spans 2 pages: 33