I was wondering how to excactly change name while uploading a file. I have a text input "name", so I tried to put $_POST['name'] to moveuploadedfile function, but with no result. Where exactly should I place it?
html
<form id="upload" enctype="multipart/form-data" action="upload.php"method="post">
<input type="text" name="name" placeholder="name" />
<input type="text" name="watermark" placeholder="watermakr" />
<input type="file" name="file" /><br />
<input type="submit" value="send" />
</form>
php
$uploads_dir ='/usr/local/apache/htdocs/images/';
$target_file = $uploads_dir . basename($_FILES["file"]["name"]);
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
// Allow certain file formats
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg") {
echo "Only JPG, JPEG, PNG files are allowed.";
$uploadOk = 0;
}
if ($uploadOk == 0) {
echo "ERROR";
// if everything is ok, try to upload file
}
else {
if (move_uploaded_file($_FILES["file"]["tmp_name"], $target_file)) {
echo "File". basename( $_FILES["file"]["name"]). " was sent.";