By pramodrs on
Hi
I am using drupal5.7 .I have created a custom page(using create content -> page) for uploading video.created the page by taking the html source code of the drupal video upload page. When user submits the page I called "node_form_submit" function.But I found that my node table is updated but in the video table the vtype and vidfile is found blank and the file is not uploaded.
Below is the code I am using.Any help will be appreciated
<?php
global $user;
//print_r($_FILES);
if(isset($_POST['op'])) {
$form_val['created'] = time();
$form_val['title'] = $_POST['title'];
$form_val['type'] = 'video';
$form_val['format'] = $_POST['format'];
$form_val['vresolution'] = $_POST['vresolution'];
$form_val['playtime_hours'] = 0;
$form_val['playtime_minutes'] = 0;
$form_val['playtime_seconds'] = 0;
$form_val['video_upload_file'] = "";
$form_val['vidfile'] = "";
$form_val['uid'] = $user->uid;
$form_val['name'] = $user->name;
$form_val['revision'] = $_POST['revision'];
$form_val['promote'] = $_POST['promote'];
$form_val['changed'] = $_POST['changed'];
$form_val['sticky'] = $_POST['sticky'];
$form_val['status'] = $_POST['status'];
$form_val['form_tocken'] = $_POST['form_tocken'];
node_form_submit('node-form',$form_val);
}
?>
<form action="" accept-charset="UTF-8" method="post" id="node-form" enctype="multipart/form-data">
<div class="form-item">
<label for="edit-title">Title: <span class="form-required" title="This field is required.">*</span></label>
<input type="text" maxlength="128" name="title" id="edit-title" size="60" value="" class="form-text required" />
</div>
<div class="form-item">
<label for="edit-video-upload-file">Upload video file: </label>
<input type="file" name="files[video_upload_file]" class="form-file" id="edit-video-upload-file" size="40" />
<div class="description">The uploaded file will be used as video file for this node.<br /><b>NOTE:</b> The max upload size is 2 MB.</div>
</div>
<div class="form-item">
<label for="edit-vresolution">Resolution: <span class="form-required" title="This field is required.">*</span></label>
<select name="vresolution" class="form-select required" id="edit-vresolution" ><option value="1">4:3 - Television</option><option value="2">16:9 - Widescreen</option></select>
</div>
<input type="hidden" name="revision" id="edit-revision" value="0" />
<input type="hidden" name="promote" id="edit-promote" value="1" />
<input type="hidden" name="changed" id="edit-changed" value="" />
<input type="hidden" name="sticky" id="edit-sticky" value="0" />
<input type="hidden" name="status" id="edit-status" value="1" />
<input type="hidden" name="form_token" id="edit-video-node-form-form-token" value="<?php print drupal_get_token('node-form'); ?>" />
<legend>Input format</legend><div class="form-item">
<label class="option"><input type="radio" name="format" value="1" checked="checked" class="form-radio" /> Filtered HTML</label>
</div>
<div class="form-item">
<label class="option"><input type="radio" name="format" value="2" class="form-radio" /> PHP code</label>
<input type="submit" name="op" id="edit-submit" value="Submit" class="form-submit" />
</div>
</form>
Comments
Since I am about to add
Since I am about to add video uploading to my site I am just curious if you tried using any of the video modules and if not why?
I tried using video module
I tried using video module and the video upload page of drupal works fine, but I want to change the design of the page and add some new fields and . So I tried using my own page for video upload but It is not working using my page :(
=-=
I believe you want to use the hook form alter function in drupal rather then trying to recreate the page itself.
see: http://api.drupal.org/api/function/hook_form_alter/5 for more information
_____________________________________________________________________
My posts & comments are usually dripping with sarcasm.
If you ask nicely I'll give you a towel : )
Recreating the form is not
Recreating the form is not recommended? can anyone please tell me if it will work?
hi can u please give me some
hi can u please give me some more info about altering a form using hook.. thanks