私は1つの問題に直面しています。問題を介して記事を送信するフォームがあり$.ajax()
ます。ファイルをアップロードするオプションをユーザーに提供していて、ページを更新したくないので、記事を送信するメインフォーム内にアップロードフォームを配置しました。フォームをネストできないようです。また、$_FILES
配列内のファイルの値も必要です。
これが私のHTMLフォームです:
<form action="/" id="upload-form">
<fieldset>
<p class="upload-result">
<!-- result of upload goes here -->
</p>
<p class="upload-images">
<label><?php _e('Upload Images','sofa'); ?></label><a href="" class="button-secondary img_add_upload"><?php _e('Upload Image','sofa'); ?></a><a href="" class="button-secondary img_add_url"><?php _e('Add Image URL','sofa'); ?></a>
</p>
<p class="upload-url">
<input type="text" name="img_url" id="img_url" value="<?php _e('Enter URL of image here...','sofa'); ?>" /><a href="" class="button-secondary img_add"><?php _e('Add Image','sofa'); ?></a>
</p>
<p class="upload-file">
<input type="file" id="async-upload" name="async-upload" size="47" /><a href="" class="button-secondary img_upload"><?php _e('Upload','sofa'); ?></a>
</p>
<ol class="upload-images-lib">
<li></li>
</ol><div class="clear"></div>
<p class="upload-images-note"><?php printf(__('Click on image to view full size. To mark image as main/featured, add image then click on %s icon.','sofa'), '<img src="'.get_bloginfo('template_directory').'/img/box.png" alt="" />'); ?></p>
<p class="upload-input">
<label for="utitle"><?php _e('Title','sofa'); ?></label>
<input type="text" name="utitle" id="utitle" value="" />
<span><?php _e('Enter a good title that describes what you are publishing. Be creative!','sofa'); ?></span>
</p>
<p class="upload-input">
<label for="cat"><?Php _e('Category','sofa'); ?></label>
<?php wp_dropdown_categories('hide_empty=0'); ?>
</p>
<p class="upload-editor">
<?php wp_editor( '', 'ucontent', $settings = array(
'textarea_rows' => 8,
'textarea_name' => 'ucontent'
)); ?>
</p>
<p class="upload-input">
<label for="utags"><?php _e('Tags','sofa'); ?></label>
<input type="text" name="utags" id="utags" value="" />
<span><?php _e('Enter a comme seperated list of tags that perfectly describe your post. e.g. funny, man, public','sofa'); ?></span>
</p>
<p class="upload-submit">
<input type="submit" value="<?php _e('Publish','sofa'); ?>" class="gradient-link-normal" />
</p>
</fieldset>
</form>
問題はこの部分にあります。
<p class="upload-file">
<input type="file" id="async-upload" name="async-upload" size="47" /><a href="" class="button-secondary img_upload"><?php _e('Upload','sofa'); ?></a>
</p>
これをクリックすると、ファイルのアップロードを処理したいのですが、ファイルのアップロードを行うPHPフォームには、$_FILES
明らかに配列が必要です。
これが可能かどうかはわかりません。解決策はありますか?