I have an image upload form that works fine on every browser except safari. The form looks like this:
<form enctype="multipart/form-data" name="file_upload" id="file_upload" action="/demo/upload_pics.php" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000" />
<input type="hidden" name="item_id" value="6" />
<p><strong>Add photo for item named 'First Item Added'</strong></p>
<p> Maximum image size is 3 MB, file types accepted: GIF, JPEG, PNG.<br>
Large images will be automatically proportionally resized to no more than 600 pixels wide and 1,200 pixels high.<br>
</p>
<table>
<tr>
<td>Local File:</td>
<td><input type="file" name="picture" size="35"/></td>
</tr>
<tr>
<td align="right" colspan="2"><input type="submit" name="submit" value="Upload" onClick="showUpload();"/>
<input type="button" name="cancel" value="Cancel" onClick="window.close();"/>
</td>
</tr>
</table>
</form>
The problem i'm having is that $_FILES['picture']['tmp_name'] is empty! My code reports "Could not place image. Uploaded file could not be found."
the code handling the POST looks like this:
// HANDLE POST
if (isset($_POST['submit'])) {
$_POST = db_escape_recursive($_POST);
$errors = array();
if (!is_array($_FILES)) {
$errors[] = "No files were posted for upload.";
}
$tmp_name = $_FILES['picture']['tmp_name'];
$filename = $_FILES['picture']['name'];
$filesize = $_FILES['picture']['size'];
$filetype = $_FILES['picture']['type'];
if (empty($tmp_name)) {
$errors[] = "Could not place image. Uploaded file could not be found.";
show_form($errors);
}
if (empty($filename)) {
$errors[] = "Could not place image. User filename not provided.";
show_form($errors);
}
if (empty($filesize)) {
$errors[] = "Could not place image. Filesize not specified.";
show_form($errors);
}
// ... ETC.
}
I have googled around for safari and upload problems and i found this other post on phpbuilders which hints that you might have to put "formdata" instead of "form-data" in the enctype attribute of the form in order for image upload to work on safari:
http://www.phpbuilder.com/board/showthread.php?t=10283522
has anyone else encountered this problem?