I am trying to upload images with a form to my webserver but the $_FILES['file'] can't find my file.
Its designed only for mobiles and I'm using Contao as CMS. I can upload with files on the server if I use a new Page that wasn't generated by Contao or jQtouch. The code down is implemented in my CMS. I think there are problems with jQuery or Ajax. Is there a way I can make it work?
HTML:
<form action="/send_mail_php.php" method="post" enctype="multipart/form-data">
<ul class="edit rounded">
<li class="arrow">
<select id="Anrede">
<option value="Frau">Frau</option>
<option value="Herr">Herr</option>
</select>
</li>
<li>
<input type="text" name="Firma" placeholder="Firma*" id="firma" data-emoji_font="true" style="font-family: 'Avenir Next', Avenir, 'Segoe UI Emoji', 'Segoe UI Symbol', Symbola, EmojiSymbols !important;">
</li>
<li>
<input type="text" name="Abteilung" placeholder="Abteilung*" id="abteilung" data-emoji_font="true" style="font-family: 'Avenir Next', Avenir, 'Segoe UI Emoji', 'Segoe UI Symbol', Symbola, EmojiSymbols !important;"/>
</li>
<li>
<input type="text" name="Vorname" placeholder="Vorname*" id="vorname" data-emoji_font="true" style="font-family: 'Avenir Next', Avenir, 'Segoe UI Emoji', 'Segoe UI Symbol', Symbola, EmojiSymbols !important;"/>
</li>
<li>
<input type="text" name="Nachname" placeholder="Nachname*" id="nachname" data-emoji_font="true" style="font-family: 'Avenir Next', Avenir, 'Segoe UI Emoji', 'Segoe UI Symbol', Symbola, EmojiSymbols !important;">
</li>
<li>
<input type="tel" name="Telefon" placeholder="Telefon*" id="telefon">
</li>
<li>
<input type="email" name="Email" placeholder="E-Mail-Adresse*" id="email">
</li>
<li>
<input type="text" name="Ort" placeholder="Wo ist der Schaden?*" id="ort" data-emoji_font="true" style="font-family: 'Avenir Next', Avenir, 'Segoe UI Emoji', 'Segoe UI Symbol', Symbola, EmojiSymbols !important;">
</li>
<li>
<input type="file" name="fileToUpload" id="fileToUpload">
<li>
<textarea name="Schadensbericht" placeholder="Schadensbericht*" id="bericht" data-emoji_font="true" style="font-family: 'Avenir Next', Avenir, 'Segoe UI Emoji', 'Segoe UI Symbol', Symbola, EmojiSymbols !important;"></textarea>
</li>
<li>
Kopie an mich
<input name="checkbox" id="checkbox" type="checkbox" class="toggle">
</li>
<li>
<a name="submit" value="Upload" type="submit" style="margin-top: 10px; margin-bottom: 10px;" href="#" class="submit whiteButton">Senden</a>
</li>
</ul>
</form>
PHP:
if(isset($_POST['fileToUpload'])){
$src = $_FILES['fileToUpload']['tmp_name'];
$dst = $target_path;
if (!file_exists($src))
echo ("<br>File wasn't found<br> SRC = ".$_REQUEST['file']);
if (!is_readable($src))
echo ("<br>File is uploaded but not readable");
if (!is_writeable($destination_path))
echo ("<br>Check your permission for the destination directory");
@touch($dst);
if (!file_exists($dst))
echo ("<br>Error (?)");
if (@move_uploaded_file($_FILES['fileToUpload']['tmp_name'], "images/".$_FILES['fileToUpload']["name"])) {
$checkUpload = 'true';
}
else {
$checkUpload = 'false';
}
}
else {
echo ("<br>Error: Not working");
}
I just started programming some weeks ago and I'm really new to web development so it would help me if you'd post finished code how to fix it or a detailed instruction.