Hi,
Thank again for this code which work very well.
And again, I am trying to change without any success.
My idea, it's to propose a multi-files upload to the form. It's for send images.
I already change the extension, it was the most easy part.
But, about the part for a multi upload, it didn't work. I got the message "Unknown extension".
The changes I did are on this level
$current_file=$_FILES['file']['name'];
$extension = substr(strrchr($current_file, '.'), 1);
if (($extension!= "jpg") && ($extension != "png"))
{
die('Unknown extension');
}
$time = date("fYhis");
$new_file = $time . "." . $extension;
$destination="uploads/".$new_file;
$action = copy($_FILES['file']['tmp_name'], $destination);
if (!$action)
{
die('File copy failed');
}else{
//echo "File copy successful";
}
that I replace by
$current_file=$_FILES['file1']['name'];
$extension = substr(strrchr($current_file1, '.'), 1);
if (($extension!= "jpg") && ($extension != "png"))
{
die('Unknown extension');
}
$time = date("fYhis");
$new_file1 = $time . "." . $extension;
$destination="uploads/".$new_file1;
$action = copy($_FILES['file1']['tmp_name'], $destination);
if (!$action)
{
die('File copy failed');
}else{
//echo "File copy successful";
}
$current_file=$_FILES['file2']['name'];
$extension = substr(strrchr($current_file2, '.'), 1);
if (($extension!= "jpg") && ($extension != "png"))
{
die('Unknown extension');
}
$time = date("fYhis");
$new_file2 = $time . "." . $extension;
$destination="uploads/".$new_file2;
$action = copy($_FILES['file2']['tmp_name'], $destination);
if (!$action)
{
die('File copy failed');
}else{
//echo "File copy successful";
}
$current_file=$_FILES['file3']['name'];
$extension = substr(strrchr($current_file3, '.'), 1);
if (($extension!= "jpg") && ($extension != "png"))
{
die('Unknown extension');
}
$time = date("fYhis");
$new_file3 = $time . "." . $extension;
$destination="uploads/".$new_file3;
$action = copy($_FILES['file3']['tmp_name'], $destination);
if (!$action)
{
die('File copy failed');
}else{
//echo "File copy successful";
}
And, on the form I added
<tr>
<td valign="top">Image 1 (*jpg *png)</td>
<td height="24"><input type="file" name="file1" ></td>
</tr>
<tr>
<td valign="top">Image 2 (*jpg *png)</td>
<td height="24"><input type="file" name="file2" ></td>
</tr>
<tr>
<td valign="top">Image 3 (*jpg *png)</td>
<td height="24"><input type="file" name="file3" ></td>
</tr>
in place of
<tr>
<td valign="top">Image (*jpg *png)</td>
<td height="24"><input type="file" name="file" ></td>
</tr>
What wrong?
Thank for your answer.
Elie