i’m using the insert_attachment code in my functions.php :
function insert_attachment($file_handler,$post_id,$setthumb='false') {
// check to make sure its a successful upload
if ($_FILES[$file_handler]['error'] !== UPLOAD_ERR_OK) __return_false();
require_once(ABSPATH . "wp-admin" . '/includes/image.php');
require_once(ABSPATH . "wp-admin" . '/includes/file.php');
require_once(ABSPATH . "wp-admin" . '/includes/media.php');
$attach_id = media_handle_upload( $file_handler, $post_id );
if ($setthumb) update_post_meta($post_id,'_thumbnail_id',$attach_id);
return $attach_id;
}
and build a nice form in a static page :
<form id="new_post" name="new_post" method="post" action="" enctype="multipart/form-data">
<p><label for="first_name">ש×</label>
<input type="text" id="first_name" value="" tabindex="1" size="20" name="first_name" />
</p>
<p><label for="last_name">×שפ××</label>
<input type="text" id="last_name" value="" tabindex="1" size="20" name="last_name" />
</p>
<p><label for="tatto_artist">×קעקע</label>
<input type="text" id="tatto_artist" value="" tabindex="1" size="20" name="tatto_artist" />
</p>
<p><label for="tatto_age">××× ×קעק××¢</label>
<input type="text" id="tatto_age" value="" tabindex="1" size="20" name="tatto_age" />
</p>
<p><label for="tatto_price">×××ר</label>
<input type="text" id="tatto_price" value="" tabindex="1" size="20" name="tatto_price" />
</p>
<p><label for="tatto_name">×©× ×קעק××¢</label>
<input type="text" id="tatto_name" value="" tabindex="1" size="20" name="tatto_name" />
</p>
<p><label for="post_tags" style="float: right;width: 95px;line-height: 1; height: 50px;">ספר ×¢× ×קעק××¢</label>
<textarea id="post_tags" tabindex="3" name="post_tags" cols="30" rows="2" name="post_tags"></textarea>
</p>
<p class="upload"><label for="thumbnail">××¢×× ×ª××× × : </label>
<input type="file" name="thumbnail" id="thumbnail"/>
</p>
<p><input type="submit" value="ש××" tabindex="6" id="submit" name="submit" /></p>
<input type="hidden" name="action" value="new_post" />
<?php wp_nonce_field( 'new-post' ); ?>
</form>
as you can see, the form is in hebrew. when i’m trying to upload attachment :
if ($_FILES) {
foreach ($_FILES as $file => $array) {
$newupload = insert_attachment($file,$pid);
echo ($attach_id);
}
}
my problems begin…
the photos are loaded but if their names is in hebrew – it saves them in other names and cant find them.
for example:
name of file from my pc: סק××¦× (1).jpg
the name after i uploaded it, in the wp uploads folder : ׳¡׳§׳â¢×³Â¦×³â-1.jpg
does anyone have any ideas how to handle this situation?