My code is below. Lines that are not indented are debug lines or things I've been trying to get this to work. Basically, the 'filename' hidden input's value is not setting so on submit, the code that checks the $_POST values is returning an error because 'filename' is missing. This is within a CMS in a module that allows adding media. Either a video file can be uploaded (uploading the file itself to the server works, it's when I try to submit to save my data info to the mySQL database that the error occurs), or the option to include iframe info to embed a video from a secondary source such as youtube. Embedding video iframe info works, uploading a video file works, but saving data if a video file is uploaded does not. Any suggestions? This has been bugging me for about a week.
<div id="content_left">
<div class="section">
<div class="title_wrapper">
<div class="title_wrapper_content" id="tabmenu">
<h2><?=($media['id']) ? "Edit Media" : "Add Media";?></h2>
<ul class="section_menu right">
<li><a href="#details"><em>Details</em></a></li>
<li><a href="#files"><em>Files</em></a></li>
</ul>
</div>
</div>
<div class="section_content">
<div class="section_content_inner">
<? if(isset($errors)): ?>
<pre><? print_r($_POST); ?></pre>
<div class="section" style="padding:10px; margin-bottom:0px;">
<ul class="system_messages">
<li class="red"><span class="ico"></span>
<strong class="system_title">Please correct the following:</strong>
<ul>
<? foreach($errors as $key => $value): ?>
<li style="padding:0px; margin:0px; list-style-type:none;">
<?=inflector::humanize($value)?>
</li>
<? endforeach; ?>
</ul>
</li>
</ul>
</div>
<? endif; ?>
<form action="/<?=url::current()?>" class="search_form" method="post" name="aemedia">
<fieldset id="details">
<div class="forms">
<div class="row">
<label><span class="asterisk">*</span> Category:</label>
<div class="inputs">
<span class="input_wrapper select_wrapper" style="width:300px">
<select name="category_id" class="input-select" >
<option value="">Select a Category</option>
<? foreach ($categories as $cat): ?>
<option value="<?=$cat['id']?>" <?=($media['category_id'] == $cat['id']) ? "selected" : ""?>>
<?=($cat['level'] > 0) ? str_repeat(" ", ($cat['level']) * 5)."|__ " : ""?>
<?=ucwords(inflector::humanize($cat['name']))?>
</option>
<? endforeach; ?>
</select>
</span>
</div>
</div>
<div class="row">
<label><span class="asterisk">*</span> Title:</label>
<div class="inputs">
<span class="input_wrapper">
<input class="text" name="title" type="text" value="<?=$media['title']?>" />
</span>
</div>
</div>
<div class="row" style="overflow:visible;">
<label>Embed Video:</label>
<div class="inputs">
<textarea name="embed" class="text" style="width:400px; height:200px;" ><?=$media['embed']?></textarea>
</div>
</div>
<div class="row" style="overflow:visible;">
<label>Abstract:</label>
<div class="inputs">
<textarea name="article" class="text" style="width:400px; height:100px;" ><?=$media['article']?></textarea>
</div>
</div>
</div>
</fieldset>
<fieldset id="files">
<div class="forms">
<div class="rows">
<div id="uploader">
<input type="file" name="mediaUpload" id="Filedata" accept="*.avi;*.mov;*.mp3;*.mpeg;*.mpg;*.wmv;|Media Files" maxlength="1" title="ftype:file" class="/media/media/" disabled="disabled" />
</div>
<ul id="file_list">
<li style="text-align:center; padding:20px; font-size:14px; list-style:none; display:<?=(count($files)==0) ? "block" : "none"?>;" id="no_files">There are currently no files uploaded.</li>
<? if(count($files) != 0): ?>
<? foreach ($files as $file): ?>
<li style="border-bottom:1px solid #F1F1F1; list-style:none; padding:5px;" id="file_<?=$file['id']?>">
<input type="hidden" name="files[<?=$file['id']?>][id]" value="<?=$file['id']?>">
<input type="hidden" name="files[<?=$file['id']?>][path]" value="<?=$file['path']?>">
<? if ($media['filename'] == "") $media['filename'] = $file['path']; ?>
<? $filepath = $file['path']; ?>
<div style="float:left;">
<?=util::get_file_icon($file['path'])?>
<div class="actions_menu" style="text-align:center;">
<ul>
<li><a class="delete" href="javascript:delete_file('<?=$file['id']?>', 'media', '<?=$file['path']?>')">Delete</a></li>
</ul>
</div>
</div>
<div style="float:left; padding:0px 10px;">
<?=basename($file['psth'])?>
<?="(".@filesize(DOCROOT.$file['path'])." Bytes)"?><br />
<textarea name="files[<?=$file['id']?>][description]" style="height:60px;"><?=$file['description']?></textarea>
</div>
<div style="clear:both;"></div>
</li>
<? endforeach; ?>
<? endif; ?>
</ul>
</div>
</div>
</fieldset>
<fieldset>
<div class="forms">
<div class="row">
<div class="inputs">
<input type="submit" class="button" value="Save"> or <a href="/media/manage/" style="font-size:16px;">Cancel</a>
<!--input type="hidden" name="filename" value="<?=$media['filename'] != "" ? $media['filename'] : $file['path'] ?>"-->
<!--input type="hidden" name="filename" value="<?=$files[$file['id'][path]]?>"-->
<input type="hidden" name="filename" value="<?=$filepath?>">
</div>
</div>
</div>
</fieldset>
</form>
</div>
</div>
</div>
</div>
<div id="content_right">
<h3>Quick Tip</h3>
<p>Use this form to add/edit media postings on the website.</p>
<p>Use the Embed Video field to embed media from another source (ie. YouTube.com, etc.).</p>
<p>Use the Abstract field to give a brief description of the media.</p>
<p><strong>Note : <span class="asterisk">*</span> When embedding video code, please make the width no more than 300px.</strong></p>
</div>