Im using the answer from:
TinyMCE not grabbing content from textarea before hiding that textarea
To get TINYMCE to get content from it's text area in IE7/8.
the problem now is that it has knocked out all of my preferences, css, button preferences etc. How can I get them back?
tinyMCE.execCommand('mceAddControl', false, 'article');
tinyMCE.init({
mode : "exact",
theme : "advanced",
content_css: "/static/css/tinymce.css",
editor_selector : "article",
plugins : "imagemanager, filemanager",
setup: function(ed) {
// Add TypeKit script to the iframe header
ed.onPreInit.add(function(ed) {
// Get the DOM document object for the IFRAME
var doc = ed.getDoc();
// Create the script we will add to the header asynchronously
var jscript = "var TypekitConfig = {\n\
kitId: 'qkc2pmz'\n\
};\n\
(function() {\n\
var tk = document.createElement('script');\n\
tk.src = '//use.typekit.com/' + TypekitConfig.kitId + '.js';\n\
tk.type = 'text/javascript';\n\
tk.async = 'true';\n\
tk.onload = tk.onreadystatechange = function() {\n\
var rs = this.readyState;\n\
if (rs && rs != 'complete' && rs != 'loaded') return;\n\
try { Typekit.load(TypekitConfig); } catch (e) {}\n\
};\n\
var s = document.getElementsByTagName('script')[0];\n\
s.parentNode.insertBefore(tk, s);\n\
})();";
// Create a script element and insert the TypeKit code into it
var script = doc.createElement("script");
script.type = "text/javascript";
script.appendChild(doc.createTextNode(jscript));
// Add the script to the header
doc.getElementsByTagName("head")[0].appendChild(script);
});
},
width : "600",
height : "300",
theme_advanced_buttons1 : "formatselect,bold,italic,underline,strikethrough,sup,sub,link,unlink,removeformat,separator,bullist,numlist,blockquote,separator,charmap,separator,insertimage,insertfile",
theme_advanced_statusbar_location : "none",
force_br_newlines : false,
force_p_newlines : false,
forced_root_block : ''
});
Text Area:
$buffer .= '<div class="control-group">';
$buffer .= '<label class="control-label">Article:</label>';
$buffer .= '<div class="controls">';
$buffer .= '<textarea rows="4" cols="100" id="article" class="article" name="article">';
$buffer .= $this->registry->article['content'];
$buffer .= '</textarea>';
$buffer .= '</div>';
$buffer .= '</div>';
You need to execute
tinyMCE.execCommand('mceAddControl', false, 'article');
AFTER the tinymce.init...
Related
I have problem with upload video file - blob, to our server. I tried solve this by javascript, but I have response 403.
So I tried do it with perl, but nothing happend. I know, that when I try create and save empty txt file with perl, it works (it is upload on server). So I hoped, that it will be similar. But it doesn´t work :(
I´m very basic programmer, please apologize me.
Please, how can I save the file to the server?
Thank you very much.
<html>
<div class="left">
<div id="startButton" class="button">
Start
</div>
<h2>Preview</h2>
<video id="preview" width="160" height="120" autoplay muted></video>
</div>
<div class="right">
<div id="stopButton" class="button">
Stop
</div>
<h2>Recording</h2>
<video id="recording" width="160" height="120" controls></video>
<a id="downloadButton" class="button">
Download
</a>
<a id="uploadButton" class="button" action="upload_ML_v01.pl" method="post" enctype="multipart/form-data">
Upload
</a>
</div>
<script>
let preview = document.getElementById("preview");
let recording = document.getElementById("recording");
let startButton = document.getElementById("startButton");
let stopButton = document.getElementById("stopButton");
let downloadButton = document.getElementById("downloadButton");
let logElement = document.getElementById("log");
let uploadButton = document.getElementById("uploadButton");
let recordingTimeMS = 5000;
function log(msg) {
//logElement.innerHTML += msg + "\n";
}
function wait(delayInMS) {
return new Promise(resolve => setTimeout(resolve, delayInMS));
}
function startRecording(stream, lengthInMS) {
let recorder = new MediaRecorder(stream);
let data = [];
recorder.ondataavailable = event => data.push(event.data);
recorder.start();
log(recorder.state + " for " + (lengthInMS/1000) + " seconds...");
let stopped = new Promise((resolve, reject) => {
recorder.onstop = resolve;
recorder.onerror = event => reject(event.name);
});
let recorded = wait(lengthInMS).then(
() => recorder.state == "recording" && recorder.stop()
);
return Promise.all([
stopped,
recorded
])
.then(() => data);
}
function stop(stream) {
stream.getTracks().forEach(track => track.stop());
}
startButton.addEventListener("click", function() {
navigator.mediaDevices.getUserMedia({
video: true,
audio: false
}).then(stream => {
preview.srcObject = stream;
downloadButton.href = stream;
preview.captureStream = preview.captureStream || preview.mozCaptureStream;
return new Promise(resolve => preview.onplaying = resolve);
}).then(() => startRecording(preview.captureStream(), recordingTimeMS))
.then (recordedChunks => {
let recordedBlob = new Blob(recordedChunks, { type: "video/webm" });
//upload it to server part start............................
var xhr = new XMLHttpRequest();
var fd = new FormData();
fd.append("video",recordedBlob);
xhr.open('POST', 'video', recordedBlob)
xhr.send(fd);
recording.src = URL.createObjectURL(recordedBlob);
downloadButton.href = recording.src;
downloadButton.download = "RecordedVideo.webm";
log("Successfully recorded " + recordedBlob.size + " bytes of " +
recordedBlob.type + " media.");
})
.catch(log);
}, false);
stopButton.addEventListener("click", function() {
stop(preview.srcObject);
}, false);
</script>
</html>
and perl file:
use strict;
use warnings;
use CGI;
use CGI::Carp qw/fatalsToBrowser/;
use File::Basename;
$|=1; # auto flush
$CGI::DISABLE_UPLOADS = 0;
my $query = CGI->new; # ..global query
my $src_filehandle = $query->upload('recording.src');
my $upld_pathfilename = "video.webm";
open (UPLOADFILE, ">",$upld_pathfilename);
my $totalbytes = 0;
while ( <$src_filehandle> ) {
print UPLOADFILE;
$totalbytes += length;
};
close UPLOADFILE
Your JavaScript code does not look right:
xhr.open('POST', 'video', recordedBlob)
The open method expects a boolean as the third argument, see documentation. You are sending it a blob instead.
Here is an example of how you can send binaray data.
I have this code on how to save multiple images to server using codeigniter and ajax
I have gone through this code, though i'm still learning Ajax, Json and Javascript. But i want to be able to save the image paths (for all images uploaded to the database so i can be able to retrieve them for each user. Just the was facebook image upload is). The code below is in my view file.
$(document).ready(function(){
$('#profiles').change(function(){
var files = $('#profiles')[0].files;
var error = '';
var form_data = new FormData();
for(var count = 0; count<files.length; count++){
var name = files[count].name;
var extension = name.split('.').pop().toLowerCase();
if(jQuery.inArray(extension, ['gif','png','jpg','jpeg']) == -1){
error += " " + count + "Invalid Image File(s)"
}
else {
form_data.append("profiles[]", files[count]);
}
}
if(error == ''){
$.ajax({
url:"<?php echo base_url(); ?>pastors/upload_image",
method:"POST",
data:form_data,
contentType:false,
cache:false,
processData:false,
beforeSend:function() {
$('#upl_images').html("<label class='text-success'>Uploading...</label>");
},
success:function(data){
$('#upl_images').html(data);
$('#profiles').val('');
document.getElementById("success_msg").style.transition="all 0.9s ease";
document.getElementById("success_msg").style.opacity=0.5;
document.getElementById("success_msg").innerHTML="Images Successfully Uploaded";
//alert(pastor +" "+ "You saved a new report");
setTimeout(remove_prodiv, 1500);
}
})
}
else{
alert(error);
}
});
});
And this is my controller
public function upload_image(){
if($_FILES["profiles"]["name"] != ''){
$output = '';
$config["upload_path"] = './programphoto/';
$config["allowed_types"] = 'gif|jpg|png|jpeg';
$this->load->library('upload', $config);
$this->upload->initialize($config);
for($count = 0; $count<count($_FILES["profiles"]["name"]); $count++){
$_FILES["file"]["name"] = $_FILES["profiles"]["name"][$count];
$_FILES["file"]["type"] = $_FILES["profiles"]["type"][$count];
$_FILES["file"]["tmp_name"] = $_FILES["profiles"]["tmp_name"][$count];
$_FILES["file"]["error"] = $_FILES["profiles"]["error"][$count];
$_FILES["file"]["size"] = $_FILES["profiles"]["size"][$count];
if($this->upload->do_upload('file')){
$data = $this->upload->data();
//$image=$data["file_name"];
//$this->pastors_model->SaveReport($image);
$output .= '
<div class="col-md-2">
<img src="'.base_url().'programphoto/'.$data["file_name"].'" class="img-responsive img-thumbnail" />
</div>
';
}
}
echo $output;
}
}
This code uploads images perfectly to the server. but i just want a way out to saving the paths to database
I got this working.
All I did was to send the file names to the model each time it uploads,
like this:
if($this->upload->do_upload('file')){
$data = $this->upload->data();
$output .= '
<div class="col-md-2">
<img src="'.base_url().'folder/'.$data["file_name"].'" class="img-responsive img-thumbnail" />
</div>
';
$filename = $data['file_name'];
$this->Model->save_file($filename);
}
I have used the jQuery UI Autocomplete demo source code for the Categories example (http://jqueryui.com/autocomplete/#categories) and have it working (querying a database which returns a JSON array).
I'm building a search function for an art gallery and my categories are Artists and Exhibitions. I want to show results from one or both categories. My problem is that results are only showing when the search term covers a result in both categories.
My suggestions script uses the search term to query two different database tables. I format and append the results into a single JSON array with rows for ["id"], ["value"], ["label"] and ["category"].
So for the search term CORN, the results that come back might be:
{ label: "Christopher Corner", category: "Artists" },
{ label: "New Pictures From Cornwall", category: "Exhibitions" },
{ label: "Cornie Collins", category: "Artists" },
At the moment when I type a search term, the possible results are only shown as long as a result is possible in ALL my categories, rather than what I want, which is one or more. So when I type CORN, I can see an Artist named Corner, and an Exhibition about Cornwall, but the minute I type the E of CORNE, all the options disappear, including the Artist whose name is Corner (which I would expect to remain).
I'm new to jQuery and jQuery UI and struggling to understand where the logic would be to select a list item from any category rather than all of them.
I have edited to add my code. This is the backend suggestions file - search_suggestions.php:
<?php
# if the 'term' variable is not sent with the request, exit
if (!isset($_REQUEST['term'])) {
exit;
}
# retrieve the search term that autocomplete sends
$term = trim(strip_tags($_GET['term']));
$a_json = array();
$a_json_row = array();
# connect to database, send relevant query and retrieve recordset
include 'includes/db_access.php';
$compoundFind = $fm->newCompoundFindCommand('web_Artists');
$request1 = $fm->newFindRequest('web_Artists');
$request2 = $fm->newFindRequest('web_Artists');
$request1->addFindCriterion('Last name', '*'.$term.'*');
$request2->addFindCriterion('First name', '*'.$term.'*');
$compoundFind->add(1, $request1);
$compoundFind->add(2, $request2);
$compoundFind->addSortRule('Last name', 1, FILEMAKER_SORT_ASCEND);
$result = $compoundFind->execute();
if (FileMaker::isError($result)) {
die();
}
$records = $result->getRecords();
# loop through records compiling JSON array
foreach ($records as $record) {
$artistID = htmlentities(stripslashes($record->getRecordID())) ;
$artistName = htmlentities(stripslashes($record->getField('Full name'))) ;
$a_json_row["id"] = $artistID;
$a_json_row["value"] = $artistName;
$a_json_row["label"] = $artistName;
$a_json_row["category"] = "Artists";
array_push($a_json, $a_json_row);
}
$findCommand = $fm->newFindCommand('web_Exhibitions');
$findCommand->addFindCriterion('Title', '*'.$term.'*');
$result = $findCommand->execute();
if (FileMaker::isError($result)) {
die();
}
$records = $result->getRecords();
foreach ($records as $record) {
$exhibitionID = htmlentities(stripslashes($record->getField('Exhibition ID'))) ;
$exhibitionTitle = htmlentities(stripslashes($record->getField('Title'))) ;
$a_json_row["id"] = $exhibitionID;
$a_json_row["value"] = $exhibitionTitle;
$a_json_row["label"] = $exhibitionTitle;
$a_json_row["category"] = "Exhibitions";
array_push($a_json, $a_json_row);
}
echo json_encode($a_json);
flush();
?>
And here is the JS in my section which sets things up:
<style>
.ui-autocomplete-category {
font-weight: bold;
padding: .2em .4em;
margin: .8em 0 .2em;
line-height: 1.5;
}
</style>
<script>
$.widget( "custom.catcomplete", $.ui.autocomplete, {
_create: function() {
this._super();
this.widget().menu( "option", "items", "> :not(.ui-autocomplete-category)" );
},
_renderMenu: function( ul, items ) {
var that = this,
currentCategory = "";
$.each( items, function( index, item) {
var li;
if ( item.category != currentCategory ) {
ul.append( "<li class='ui-autocomplete-category'>" + item.category + "</li>" );
currentCategory = item.category;
}
li = that._renderItemData( ul, item );
if ( item.category ) {
li.attr( "aria-label", item.category + " : " + item.label );
}
});
}
});
</script>
<script>
$(function() {
$( "#searchInput" ).catcomplete({
minLength: 2,
source:'search_suggestions.php'
});
});
</script>
Finally this is the actual input field on the page:
<input class="u-full-width" placeholder="Search" id="searchInput" />
Sorry if this is too much code!
My website is sometimes getting a 303 redirect loop on the main page. This gives me an error when trying to view the site "the webpage has a redirect loop", but most of the time is loads fine. But, the 303 redirect doesn't look good for SEO. I'm running the Joomla 3.2.3 with the Zo2 framework. I used the firefox live http headers tool and this is what it shows:
HTTP/1.1 303 See other
Date: Sat, 19 Apr 2014 06:42:44 GMT
Server: Apache mod_fcgid/2.3.10-dev
X-Powered-By: PHP/5.4.26
Set-Cookie: 81f5073a1f9d10dc244e07c98216335e=hb7mb5k3v0vftstcgtdbonikq6; path=/; HttpOnly
Location: /
Cache-Control: max-age=600
Expires: Sat, 19 Apr 2014 06:52:44 GMT
Content-Length: 0
Keep-Alive: timeout=5
Connection: Keep-Alive
I went through and disable every plugin in Joomla one at a time and when I disable the Zo2 framework plugin the 303 redirect went away. I've asked on their forums and they haven't been able to help me. So, I searched through all of the files in the zo2 plugin directory for the word redirect and this is what I found.
These two are in the site.megamenu.js
!function ($) {
$(document).ready(function ($) {
// when clicking on menu
redirect();
var duration = 0;
var $parent = $('.zo2-megamenu');
var hover_type = $parent.data('hover');
if ($parent.data('duration')) {
duration = $parent.data('duration');
}
function redirect() {
$('.dropdown-toggle').on('click',function(e){
if($(this).parent().hasClass('open') && this.href && this.href != '#'){
window.location.href = this.href;
e.preventDefault();
}
});
}
I have other website running on this server using the same .htaccess and php.ini files so I don't think that could be the problem, because they are not getting a redirect. I would appreciate some help with this. The website is http://www.betterfreestuff.com
/**
* Zo2 Framework (http://zo2framework.org)
*
* #link http://github.com/aploss/zo2
* #package Zo2
* #author Hiepvu
* #copyright Copyright ( c ) 2008 - 2013 APL Solutions
* #license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 or Later
*/
!function ($) {
$(document).ready(function ($) {
// when clicking on menu
redirect();
var duration = 0;
var $parent = $('.zo2-megamenu');
var hover_type = $parent.data('hover');
if ($parent.data('duration')) {
duration = $parent.data('duration');
}
if (duration && (hover_type == 'hover')) {
var timeout = duration ? duration + 50 : 500;
$('.nav > li, li.mega').hover(
function(e) {
onMouseIn(this, timeout);
}
,
function (e) {
onMouseOut(this);
}
);
} else if (hover_type == 'click') {
$('.mega-nav').find('.dropdown-submenu').hover(
function(e) {
onMouseIn(this, 100);
}
,
function (e) {
onMouseOut(this);
}
);
}
// for first li tag
function redirect() {
$('.dropdown-toggle').on('click',function(e){
if($(this).parent().hasClass('open') && this.href && this.href != '#'){
window.location.href = this.href;
e.preventDefault();
}
});
}
function onMouseIn (e, timeout) {
var $this = $(e);
if ($this.hasClass('mega')) {
$this.addClass ('hovering');
clearTimeout ($this.data('hoverTime'));
$this.data('hoverTime',
setTimeout(function(){$this.removeClass ('hovering')}, timeout));
clearTimeout ($this.data('hoverTime'));
$this.data('hoverTime',
setTimeout(function(){$this.addClass ('open')}, 100));
} else {
clearTimeout($this.data('hoverTime'));
$this.data('hoverTime',
setTimeout(function () {
$this.addClass('open')
}, 100));
}
}
function onMouseOut (e) {
var $this = $(e);
clearTimeout($this.data('hoverTime'));
$this.data('hoverTime',
setTimeout(function () {
$this.removeClass('open')
}, 100));
}
/** BEGIN: off canvas menu **/
var showOffCanvasMenu = function () {
var $offcanvas = $('.offcanvas');
var $body = $('body');
var $wrapper = $('.wrapper');
$body.addClass('overflow-hidden');
$wrapper.addClass('offcanvas-push');
var $overlay = $('<div />').addClass('offcanvas-overlay').appendTo('body');
$overlay.css({
top:0,
right:0,
bottom:0
}).fadeIn();
$overlay.click(function() {
$body.removeClass('overflow-hidden');
$wrapper.removeClass('offcanvas-push');
$offcanvas.removeClass('active');
$('.offcanvas-overlay').remove();
});
};
var hideOffCanvasMenu = function () {
var $body = $('body');
var $wrapper = $('.wrapper');
var $offcanvas = $('.offcanvas');
$body.removeClass('overflow-hidden');
$wrapper.removeClass('offcanvas-push');
$offcanvas.removeClass('active');
$('.offcanvas-overlay').remove();
};
$('[data-toggle=offcanvas]').click(function() {
var $offcanvas = $('.offcanvas');
$offcanvas.toggleClass('active');
if ($offcanvas.hasClass('active')) {
showOffCanvasMenu();
}
else {
hideOffCanvasMenu();
}
});
$('body').on('click', '.sidebar-nav a', function() {
if (!$(this).hasClass('nav-oc-toggle')) hideOffCanvasMenu();
});
$('body').on('click', '.sidebar-close', function() {
hideOffCanvasMenu();
});
// new off canvas submenu
$('body').on('click', '.nav-oc-toggle', function() {
var $this = $(this);
var $parent = $this.closest('.nav-parent');
if ($parent.find('> .submenu').hasClass('in')) $this.removeClass('icon-caret-up').addClass('icon-caret-down');
else $this.removeClass('icon-caret-down').addClass('icon-caret-up');
});
/** END: off canvas menu **/
});
}(jQuery);
I searched for 303 in all of the files on my server and these files came back with redirect statements.
cms.php
public function redirect($url, $moved = false)
{
// Handle B/C by checking if a message was passed to the method, will be removed at 4.0
if (func_num_args() > 1)
{
$args = func_get_args();
/*
* Do some checks on the $args array, values below correspond to legacy redirect() method
*
* $args[0] = $url
* $args[1] = Message to enqueue
* $args[2] = Message type
* $args[3] = $moved
*/
if (isset($args[1]) && !empty($args[1]) && !is_bool($args[1]))
{
// Log that passing the message to the function is deprecated
JLog::add(
'Passing a message and message type to JFactory::getApplication()->redirect() is deprecated. '
. 'Please set your message via JFactory::getApplication()->enqueueMessage() prior to calling redirect().',
JLog::WARNING,
'deprecated'
);
$message = $args[1];
// Set the message type if present
if (isset($args[2]) && !empty($args[2]))
{
$type = $args[2];
}
else
{
$type = null;
}
// Enqueue the message
$this->enqueueMessage($message, $type);
// Reset the $moved variable
$moved = isset($args[3]) ? (boolean) $args[3] : false;
}
}
application.php
public function redirect($url, $msg = '', $msgType = 'message', $moved = false)
{
// Check for relative internal links.
if (preg_match('#^index2?\.php#', $url))
{
$url = JUri::base() . $url;
}
// Strip out any line breaks.
$url = preg_split("/[\r\n]/", $url);
$url = $url[0];
/*
* If we don't start with a http we need to fix this before we proceed.
* We could validly start with something else (e.g. ftp), though this would
* be unlikely and isn't supported by this API.
*/
if (!preg_match('#^http#i', $url))
{
$uri = JUri::getInstance();
$prefix = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port'));
if ($url[0] == '/')
{
// We just need the prefix since we have a path relative to the root.
$url = $prefix . $url;
}
else
{
// It's relative to where we are now, so lets add that.
$parts = explode('/', $uri->toString(array('path')));
array_pop($parts);
$path = implode('/', $parts) . '/';
$url = $prefix . $path . $url;
}
}
// If the message exists, enqueue it.
if (trim($msg))
{
$this->enqueueMessage($msg, $msgType);
}
// Persist messages if they exist.
if (count($this->_messageQueue))
{
$session = JFactory::getSession();
$session->set('application.queue', $this->_messageQueue);
}
// If the headers have been sent, then we cannot send an additional location header
// so we will output a javascript redirect statement.
if (headers_sent())
{
echo "<script>document.location.href='" . str_replace("'", "'", $url) . "';</script>\n";
}
else
{
$document = JFactory::getDocument();
jimport('phputf8.utils.ascii');
if (($this->client->engine == JApplicationWebClient::TRIDENT) && !utf8_is_ascii($url))
{
// MSIE type browser and/or server cause issues when url contains utf8 character,so use a javascript redirect method
echo '<html><head><meta http-equiv="content-type" content="text/html; charset=' . $document->getCharset() . '" />'
. '<script>document.location.href=\'' . str_replace("'", "'", $url) . '\';</script></head></html>';
}
else
{
// All other browsers, use the more efficient HTTP header method
header($moved ? 'HTTP/1.1 301 Moved Permanently' : 'HTTP/1.1 303 See other');
header('Location: ' . $url);
header('Content-Type: text/html; charset=' . $document->getCharset());
}
}
$this->close();
}
web.php
public function redirect($url, $moved = false)
{
// Import library dependencies.
jimport('phputf8.utils.ascii');
// Check for relative internal links.
if (preg_match('#^index\.php#', $url))
{
// We changed this from "$this->get('uri.base.full') . $url" due to the inability to run the system tests with the original code
$url = JUri::base() . $url;
}
// Perform a basic sanity check to make sure we don't have any CRLF garbage.
$url = preg_split("/[\r\n]/", $url);
$url = $url[0];
/*
* Here we need to check and see if the URL is relative or absolute. Essentially, do we need to
* prepend the URL with our base URL for a proper redirect. The rudimentary way we are looking
* at this is to simply check whether or not the URL string has a valid scheme or not.
*/
if (!preg_match('#^[a-z]+\://#i', $url))
{
// Get a JUri instance for the requested URI.
$uri = JUri::getInstance($this->get('uri.request'));
// Get a base URL to prepend from the requested URI.
$prefix = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port'));
// We just need the prefix since we have a path relative to the root.
if ($url[0] == '/')
{
$url = $prefix . $url;
}
// It's relative to where we are now, so lets add that.
else
{
$parts = explode('/', $uri->toString(array('path')));
array_pop($parts);
$path = implode('/', $parts) . '/';
$url = $prefix . $path . $url;
}
}
// If the headers have already been sent we need to send the redirect statement via JavaScript.
if ($this->checkHeadersSent())
{
echo "<script>document.location.href='" . str_replace("'", "'", $url) . "';</script>\n";
}
else
{
// We have to use a JavaScript redirect here because MSIE doesn't play nice with utf-8 URLs.
if (($this->client->engine == JApplicationWebClient::TRIDENT) && !utf8_is_ascii($url))
{
$html = '<html><head>';
$html .= '<meta http-equiv="content-type" content="text/html; charset=' . $this->charSet . '" />';
$html .= '<script>document.location.href=\'' . str_replace("'", "'", $url) . '\';</script>';
$html .= '</head><body></body></html>';
echo $html;
}
else
{
// All other cases use the more efficient HTTP header for redirection.
$this->header($moved ? 'HTTP/1.1 301 Moved Permanently' : 'HTTP/1.1 303 See other');
$this->header('Location: ' . $url);
$this->header('Content-Type: text/html; charset=' . $this->charSet);
}
}
I seem to have a problem with uploadify. It always get stuck at 100% on the first file, no matter what the file is. I am using Zend on my Wamp and it works fine there but as soon as I upload it on my linux server it gets stuck. The file is uploaded and renamed but it never fires the onComplete event and stays at 100% on the first file.
Here is my javascript:
$('#fileInput').uploadify({
'uploader' : 'http://test.thevenuelist.co.uk/js/uploadify/uploadify.swf',
'script' : 'http://test.thevenuelist.co.uk/ajax/uploadify',
'cancelImg' : 'http://test.thevenuelist.co.uk/js/uploadify/cancel.png',
'folder' : '/userdata/images/',
'auto' : true,
'multi' : true,
'fileDesc' : 'Image Files (*.jpg;*.jpeg;*.gif;*.png)',
'fileExt' : '*.jpg;*.jpeg;*.gif;*.png',
'buttonText' : 'Upload Images',
'removeCompleted' : true,
'onComplete' : function (event, queueID, fileObj, response, data) {
var answer = eval('(' + response + ')');
if(answer.result == "success")
{
$("#hdnImages").val($("#hdnImages").val() + answer.fileName + ",");
var toAdd = "<li><img src='/images/delete.png' id='removeItem' rel='"+answer.fileName+"' style='cursor:pointer;' title='Remove' alt='Remove'/> Image "+answer.realName+" uploaded</li>";
$("#completedItemsList").append(toAdd);
}
},
'onError': function (event, queueID ,fileObj, errorObj) {
alert(errorObj.info);
}
});
And here is my Zend code behind:
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT']. '/' . $_REQUEST['folder'] . '/';
$fileNameArray = explode('.',$_FILES['Filedata']['name']);
$hash = substr(md5(microtime()),0,5);
$finalFileName = $fileNameArray[0].$hash.'.'.$fileNameArray[1];
$targetFile = str_replace('//','/',$targetPath) . $finalFileName;
if(move_uploaded_file($tempFile,$targetFile))
{
$data = array("result"=>"success","fileName"=>$finalFileName,"realName"=>$_FILES['Filedata']['name']);
}
else
{
$data = array("result"=>"failed");
}
echo Zend_Json::encode($data);
Any help would be greatly appreciated. I have spent way too much time trying to figure it out. I need my onComplete event to work so I can finish my forms.
I found with uploadify I had to return either a 1 or a 0 for success or failure to get it to work.