I am trying to allow the user to upload as many images as they want, place them all in a new directory based on the title of the form, and then write that folder name to the database and I will call it later to do an image dump.
So I have been working on this for multiple days now, and have gotten this far
if(isset($_POST['Submit']))
{ $ttitle = $_POST['ttitle'];
$file_dir = './../img/treatments/';
foreach( $_FILES as $file_name => $file_array ){
$current_image=$_FILES['image']['name'][0];
$extension = substr(strrchr($current_image, '.'), 1);
if (($extension!= "png") && ($extension != "jpg"))
{
die('Unknown extension');
}
$time = date("fYhis");
$new_image = $time . "." . $extension;
$new_dir = mkdir("./../img/treatments/" . $ttitle, 0700);
$destination= $new_dir && $new_image;
$action = copy($_FILES['image']['tmp_name'], $destination);
}
$last_name = $_POST['last_name'];
$username = $_POST['username'];
$pass = $_POST['pass'];
$text = $_POST['text'];
$bio = $_POST['bio'];
$tsub = $_POST['tsub'];
$image = $ttitle;
if (!$action)
{
die('File copy failed');
}else{
echo "File copy successful";
}
and then the html form
<form method='post' enctype='multipart/form-data' action='#'>
<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td width="40%" class="right">
Title: </td><td width="60%" class="left"><input type="text" autofocus autofocus="autofocus" required required="required" name="ttitle" maxlength="255"
/>
*</td></tr><tr><td class="right">
Subtitle:</td><td class="left"> <input type="text" required required="required" name="tsub" maxlength="255"
/>
*</td></tr><tr><td class="right">
Username: </td><td class="left"><input type="text" required required="required" name="username" maxlength="255"
/>
*</td></tr><tr><td class="right">
Password: </td><td class="left"><input type="password" required required="required" name="pass" maxlength="255"
/>
*</td></tr>
<tr><td class="right">
Confirm Password: </td><td class="left"><input type="password" required required="required" name="pass2" maxlength="255"
/>
*</td></tr><tr><td class="right">Proposed Director
</td><td class="left"><input type="text" name="dir" maxlength="255"
/>
*</td></tr><tr><td class="right">Proposed Additional
</td><td class="left"><input type="text" name="add" maxlength="255"
/></td></tr><tr><td class="right" valign="top">
Text: </td><td class="left" valign="top"><textarea required required="required" name="text"></textarea>
*</td></tr><tr><td class="right">
Bobblehead: </td><td class="left">
<input type="file" required required="required" name="image[]" multiple="">
*</td></tr> </table>
And now everything works with the exception of actually copying and writing the files to the new directory, I am sitting here fiddling with it but I feel like I am real close and some one probably has the key, I just can't figure it out off the top of my head. Any help would be great, thanks.
$new_dirand combine it with$new_imgso it will beurl/folder/image.jpg