• Welcome to PHPVIBE Forums. Please log in.

[ Video Sharing CMS v4 ] Allow user to upload their subtitle, thumbnail

Started by vinh,

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

vinhTopic starter

Hello, I want to allow user to upload their subtitle, thumbnail via panel, I have try to edit code /tpl/main/manager.php by adding the follwing code but it doesnot work, Please help me to fix it. THank you all.


<?php if(isset($_POST['edited-video']) && !is_null(intval($_POST['edited-video']))) {
if(isset($_FILES['play-img']) && !empty($_FILES['play-img']['name'])){
$formInputName   = 'play-img';							# This is the name given to the form's file input
	$savePath	     = ABSPATH.'/'.get_option('mediafolder').'/thumbs';								# The folder to save the image
	$saveName        = md5(time()).'-'.user_id();									# Without ext
	$allowedExtArray = array('.jpg', '.png', '.gif');	# Set allowed file types
	$imageQuality    = 100;
$uploader = new FileUploader($formInputName, $savePath, $saveName , $allowedExtArray);
if ($uploader->getIsSuccessful()) {
//$uploader -> resizeImage(200, 200, 'crop');
$uploader -> saveImage($uploader->getTargetPath(), $imageQuality);
$thumb  = $uploader->getTargetPath();
$thumb  = str_replace(ABSPATH.'/' ,'',$thumb);
	$db->query("UPDATE  ".DB_PREFIX."videos SET thumb='".toDb($thumb )."' WHERE id = '".intval($_POST['edited-video'])."'");
}

} else {
$db->query("UPDATE ".DB_PREFIX."videos SET thumb='".toDb($_POST['remote-img'])."' WHERE id = '".intval($_POST['edited-video'])."'");
}
if(isset($_FILES['subtitle']) && !empty($_FILES['subtitle']['name'])){
$fp = ABSPATH.'/'.get_option('mediafolder')."/";
$extension = end(explode('.', $_FILES['subtitle']['name']));
$srt_path = $fp.'subtitle-'.intval($_POST['edited-video']).'.'.$extension;
$srt = 'subtitle-'.intval($_POST['edited-video']).'.'.$extension;
if (move_uploaded_file($_FILES['subtitle']['tmp_name'], $srt_path)) {
$db->query("UPDATE  ".DB_PREFIX."videos SET srt='".toDb($srt)."' WHERE id = '".intval($_POST['edited-video'])."'");

	echo '<div class="msg-win">New subtitle file uploaded.</div>';
	} else {
	echo '<div class="msg-warning">Subtitle upload failed.</div>';
	}
	
}

?>

<div class="control-group">
	<label class="control-label">Subtitle</label>
	<div class="controls">
	<div class="row-fluid">
	<div class="span6">
<input type="file" id="subtitle" name="subtitle" class="styled" />
<span class="help-block" id="limit-text">Choose a .srt file</span>
</div>
<div class="span6">
<?php if($video->srt) {
echo $video->srt;
} else {
echo "No subtitle attached yet";
}
	?>
</div>
</div>
</div>
</div>
  •  

PHPVibe A.

Show me your final code, and which file you've edited.

One thing I can imagine is that in moderator you have

$_POST['edited-video']

and in com_add you have

intval($doit->id)

as video id, but there may be other differences, so need to see your trial code.

vinhTopic starter

Hello, I tried to add code to /tpl/main/manager.php to add function allow member to upload subtitle and thumbnail. The code above is from the edit-video code in admincp.
  •  

vinhTopic starter

Hello, Can anyone here help me to do this :( Thanks very much,!
  •  

PHPVibe A.

Quote from: vinh on
Hello, I tried to add code to /tpl/main/manager.php to add function allow member to upload subtitle and thumbnail. The code above is from the edit-video code in admincp.

But there are differences, you can't just paste it. It needs bit of re-coding.
We may add it in an upgrade with option shut-down soon, right now is this problem, most employees are in vacation around.

vinhTopic starter

  •  

Similar topics (7)