I am uploading images and cropping to a directory, how do I add a text field to change the file name when uploading?
I have tried to add name field to the form but are unable to get the form to post the newname when uploading.
<form action="" method="POST" enctype="multipart/form-data">
<input id="input-6" name="art[]" type="file" multiple class="file-
loading">
<input type="text" name="newname"/>
<input type="submit" name="sub">
</form>
<?php
if(isset($_POST['sub'])){ (my guess is that "sub" needs to change to
"newname" but that does not seem to work)
if(isset($_FILES['art'])){
foreach ($_FILES["art"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["art"]["tmp_name"][$key];
$name = $_FILES["art"]["name"][$key];
$image = imagecreatefromstring(file_get_contents(($tmp_name)));
$filename = 'newimage/'.$name.'';
}
?>
NO error messages just doesn't append the file name.