I don't know whats the problem. Im trying to do an image upload script. But the choosen file is always empty(null).
Here is my form:
<form id="coffee_talk_add" action="include/scripts/add_event.php" method="post" accept-charset="utf-8" enctype="multipart/form-data">
<table>
<tr>
<td class="event_width">Datum:</td>
<td>
<select name="day_from" id="day_from_e">
<option value="none" class="bold italic">Tag</option>
<?php
for($i=1; $i<=31; $i++){
echo "<option value=\"".$i."\">".$i."</option>\n";
}
?>
</select>
<select name="month_from" id="month_from_e">
<option value="none" class="bold italic">Monat</option>
<?php
for($i=1; $i<=12; $i++){
echo "<option value=\"".$i."\">".$month_name[$i]."</option>\n";
}
?>
</select>
<select name="year_from" id="year_from_e">
<option value="none" class="bold italic">Jahr</option>
<?php
for($i=2008; $i<=$year; $i++){
echo "<option value=\"".$i."\">".$i."</option>\n";
}
?>
</select>
</td>
</tr>
<tr>
<td>Thema:</td>
<td class="topic"><input type="text" name="topic" id="topic_e" /></td>
</tr>
<tr>
<td>Referent:</td>
<td class="contributer"><input type="text" name="contributer" id="contributer_e" /></td>
</tr>
<tr>
<td>Beginn:</td>
<td class="begin"><input type="text" name="begin_hour" id="begin_hour_e" />:<input type="text" name="begin_min" id="begin_min_e" /> Uhr</td>
</tr>
<tr>
<td>Ort:</td>
<td class="place"><input type="text" name="place" id="place_e" /></td>
</tr>
<tr>
<td>Eintritt:</td>
<td class="entrance"><input type="text" name="entrance_euro" id="entrance_euro_e" />,<input type="text" name="entrance_cent" id="entrance_cent_e" /> €</td>
</tr>
<tr>
<td>Flyer:</td>
<td class="flyer">
<input type="hidden" name="MAX_FILE_SIZE" value="5734400">
<input type="file" name="image" id="image">
</td>
</tr>
</table>
<input type="hidden" name="coffee_talk_submit" value="true" />
<div id="add_coffee_talk">
<input type="submit" id="small" class="coffee_talk_submit" value="speichern">
</div>
</form>
And this is an extraction of my simple add_event.php:
if (isset($_POST['coffee_talk_submit'])) {
$file = $_FILES['image']['tmp_name'];
echo var_dump($file);
if (!isset($file)) {
//No picture choosen
echo "No file choosen";
} else {
//Do stuff
echo "upload stuff";
}
}
And here my ajax form:
$('.coffee_talk_submit').click(function(){
if ($('#year_from_e').val() == 'none' || $('#month_from_e').val() == 'none' || $('#day_from_e').val() == 'none'
|| $('#topic_e').val() == '' || $('#contributer_e').val() == '' || $('#begin_hour_e').val() == ''
|| $('#begin_min_e').val() == '' || $('#place_e').val() == '' || $('#entrance_euro_e').val() == '' || $('#entrance_cent_e').val() == '') {
$("#dialog_empty").dialog( "open" );
return false;
}
var form = $('#coffee_talk_add');
var data = form.serialize();
$.ajax({
url: "include/scripts/add_event.php",
type: "POST",
data: data,
dataType: 'json',
success: function (reqCode) {
if (reqCode['error_code'] == 1) {
//Termin erfolgreich eingetragen
$("#dialog_ok").dialog( "open" );
} else if (reqCode['error_code'] == 2) {
//Eintrag bereits vorhanden
$("#dialog_error").dialog( "open" );
}
clear_form_elements(form);
}
});
return false;
});
I looked up into info.php and found out that file_upload is allowed but temp_folder has no value. Is this the reason why my script can't find the tmp_name file? I can't change any values cause my hoster do not allow to make any changes in php.ini (can't even get access to file). If so is there any other way to handle this?