I have found some posts with the same problem I have, however, no solutions presented. I am not 100% sure what to make of this, but hope you can help.
I am attempting to use Uploadify to upload files, but the following happens:
Browse for file successful (hence my 'script' and 'uploaded' attributes are correct)
Progress bar says "100%" and completes.
onComplete fires saying upload successful (according to the path alerted, 'folder' attribute is correct.)
If I die my script before any output, the #3 step does not happen - hence it reaches the 'script' specified. After output, the script doesn't die.
FILE IS NOT FOUND IN FILESYSTEM
Not sure how this is possible - as far as I can tell, everything is correct.
Here is my code:
<script type="text/javascript">
$(document).ready(function() {
$("#addimage").validationEngine();
$('#imagefile').uploadify({
'uploader': "/js/uploadify/uploadify.swf",
'fileExt': "*.jpg;*.jpeg;*.png;*.gif",
'buttonText': "Browse...",
'script': "/js/uploadify/uploadify.php",
'cancelImg': "/js/uploadify/cancel.png",
'folder': "/uploads",
'fileDesc': 'Only *.jpg, *.jpeg, *.png, *.gif are allowed',
'auto': true,
'onComplete': function(event, ID, fileObj, response, data) {
$('#name').val('Please edit this text to add a description...');
alert('Uploaded ' + fileObj.name + ' to ' + fileObj.filePath + '.');
}
});
});
</script>
<input type="file" id="imagefile" name="imagefile" />
<?php
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
$targetFile = str_replace('//', '/', $targetPath) . 'image_' . date('YmdHis') . '_' . $_FILES['Filedata']['name'];
move_uploaded_file($tempFile,$targetFile);
echo str_replace($_SERVER['DOCUMENT_ROOT'],'',$targetFile);
}
?>
The PHP script's only change is the name of the targetFile which I have changed, to ensure some sort of unique filename (although not foolproof) but otherwise the script is the same as released (with comments removed here for brevity purposes).
Can anybody tell my why Uploadify indicates that the file upload was successful, but no file exists in the uploads directory? I am using Windows, PHP5.3, and the uploads folder is writable (I can upload files there without Uploadify, but not with it)
Thanks in advance!
Kobus
I had similar problems on a Linux machine. It turned out that the PHP configuration on my server was the cuplrit. PHP was running in SAFE MODE. As I had uploaded the Uploadify scripts via FTP, so script files were stored in the file system with my FTP user details. Since PHP's temp folder was owned by the server root, I had a UID mismatch, i.e. the temporary upload file was attributed to root while the upload script that tried to move it was owned by the FTP user. That fragged it.
To resolve this I changed the ownership of the uploadify php script to root and from there on it worked.
Related
How to change url path of socket.io.js
my socket.io.js is located at
https://192.168.236.100/socket.io/socket.io.js
what if i want to change it like:
https://192.168.236.100/socket.conference/socket.io.js
thank you
It is not as simple as changing the this._path value or passing in the path option to the constructor because if you change that, it also affects how a socket.io client must connect to the server too, not only how the socket.io.js file is served.
The simplest way I could find to make the socket.io.js file appear to be coming from a different path and not change anything else is to just create a new route for it like this:
app.get("/socket.conference/socket.io.js", function(req, res) {
res.sendFile(path.join(__dirname, "node_modules/socket.io-client/socket.io.js"));
});
This assumes that socket.io is installed locally in the directory that your app file is running from. If it is installed somewhere differently, then you need to find where the /socket.io-client/socket.io.js path/file is and use the right path to that.
This works with this client <script> tag:
<script src="/socket.conference/socket.io.js"></script>
When downloading the file via a link in grails page, following controller is working. However, somehow the downloaded file is also saved in my project structure web-app. Right now, it is running in my local host. So when moved to production, this will start saving the file in server as well. Is there any way to allow a regular download to client's machine but prevent or clean the download to server?
File uploadedInBackEndToBeDownloadedFromFrontEnd = fetchTheFileFromBackEnd() // some custom method
response.setHeader("Content-Type", "application/octet-stream;")
response.setHeader("Content-Disposition", " uploadedInBackEndToBeDownloadedFromFrontEnd ; filename=\"${ uploadedInBackEndToBeDownloadedFromFrontEnd .name}\"")
response.setHeader("Content-Length", "$ uploadedInBackEndToBeDownloadedFromFrontEnd .size()}")
response.outputStream << uploadedInBackEndToBeDownloadedFromFrontEnd .getBytes()
Thanks a lot!!
I just downloaded a fresh copy of tinymce, uploaded it and tried to use it on my UTF-8 encoded website.
The menu bar icons are either garbage because it can't find it's presentation file (font?) or the encoding of one of the 10000 files is wrong.
Anyone knowing this bug? I didn't change anything, just uploaded..
TinyMCE doesn't use my german lang file either, obviously. I placed the js file into the "langs" folder.
<script type="text/javascript">
tinyMCE.baseURL = '//example.com/de/assets/scripts/tinymce';
tinyMCE.suffix = '.min';
tinymce.init({
selector: "textarea"
});
</script>
Do I have to set any configuration for path, basepath, ... ??
My actual path to tinymce is scripts/tinymce/tinymce.min.js. The origin path provided by the shipped package was tinymce/tinymce/js/tinymce/tinymce.min.js but honestly this kind of nesting folders without any reason..
update: The paths are working, it does read files not directly linked.. (like theme.min.js) successfully.
I'm trying to run activex control for a simple hello world message box.
First i created the class library and i have now the dll , then i created the HTML page and called the activeX control :
<!DOCTYPE>
<html>
<head>
<title>DemoActiveX</title>
</head>
<body>
<OBJECT id="DemoActiveX" classid="clsid:400DCE17-4B26-4E59-9A88-AF39E2BE4A55">
</OBJECT>
<script type="text/javascript">
try {
var obj = document.DemoActiveX;
if (obj) {
alert(obj.SayHello());
} else {
alert("Object is not created!");
}
} catch (ex) {
alert("Some error happens, error message is: " + ex.Description);
}
</script>
</body>
</html>
when i tried it in my machine i used to register the dll using regasm /codebase "dll path" and it worked fine.
The problem when i tried to run in another machine, i followed the coming steps :
1) I created setup project and added the dll file.
2) I created .inf file and tried two contents which are :
[version]
signature="$CHICAGO$"
AdvancedINF=2.0
[Add.Code]
ActiveX.dll=ActiveX.dll
[ActiveX.dll]
file-win32-x86=thiscab
clsid=400DCE17-4B26-4E59-9A88-AF39E2BE4A55
FileVersion=1,0,0,0
RegisterServer=yes
[version]
signature="$CHICAGO$"
AdvancedINF=2.0
[Setup Hooks]
install=install
[install]
run=msiexec.exe /package """%EXTRACT_DIR%\DemoActiveXSetup.msi""" /qn
3) I created .CAB file which contains the .inf and setup.exe files
4) Changed the object in HTML page to be :
<OBJECT id="DemoActiveX" classid="clsid:400DCE17-4B26-4E59-9A88-AF39E2BE4A55"
codebase="ActiveXCAB.CAB" ></OBJECT>
when i tried to open the page on the other machine a request windows opened which request to open CAB ,when i press yes nothing happened !!!!!
why it doesn't open the setup.exe or msi file ??
BTW when i installed manually the setup file the activeX worked !
I solved the problem :)
The problem was :
1) I used to put msi file only or setup.exe in CAB file but i must put both msi and setup.exe and refer to setup.exe in inf file
2) inf file format was wrong , the correc one is :
[version]
signature="$CHICAGO$"
AdvancedINF=2.0
[Add.Code]
setup.exe=setup.exe
[setup.exe]
file-win32-x86=thiscab
clsid={415D09B9-3C9F-43F4-BB5C-C056263EF270}
FileVersion=1,0,0,0
[Setup Hooks]
RunSetup=RunSetup
[RunSetup]
run="%EXTRACT_DIR%\setup.exe"
Good Luck :)
I am developing an app which uses both Phonegap and JQuery Mobile.
The app connects to an external server to check for new content/content updates (html and pdf files).
If needed, in iOS those files are successfully downloaded into the app /Documents folder.
The app then retrieves each content file's absolute path (file://localhost/var/mobile/Applications/APPID/Documents/subfolder) and creates listviews that link to each file's absolute path.
The problem I am having is the following: tapping a listview opens the linked page BUT not as an ajax call. The page loads but then no javascript (cordova.js, jquery.js app.js etc) is referenced in the page and hence I can't navigate back to the main menu. It seems like the jQueryMobile ajax navigation stops working when I open html files in the /Documents folder.
This happens only for the downloaded content in the /Documents folder (and hence outside Phonegap's www folder).
From the remote debugger, if I try to call the $.mobile.changePage('previousPage.html')* function, the console returns that $ is not defined, as if the page couldn't reference jQuery. But in none of the pages in the /www folder I need to re-reference the js files.
The app uses a multipage layout and each page has its own javascript after the <div data-role="page" id="pageid"> container.
Each .html in the /Documents folder is structured as a jQueryMobile page (with data-role attributes).
This is the code that creates the listviews:
<script type="text/javascript">
$('#content').live('pagebeforeshow', function(e) {
var curCat = parseInt(window.localStorage.getItem('currentCat'));
console.log('PAGE BEFORE SHOW: CONTENT');
db.db.transaction(function(tx) {
tx.executeSql('SELECT * FROM `content` WHERE `content`.`catID` = ?', [curCat],
function(tx, result) {
var path = window.localStorage.getItem('contentPath') + '/';
if (result.rows && result.rows.length) {
var html = '<ul data-role="listview" id="linkUl">';
for (var i = 0; i < result.rows.length; i++) {
var filename = result.rows.item(i).index_file.substr(result.rows.item(i).index_file.lastIndexOf('/'));
console.log(result.rows.item(i).id);
html += '<li id="' + result.rows.item(i).id + '">';
html += '<a href="' + path + filename +'">';
html += result.rows.item(i).title;
html += '</a></li>';
}
html += '</ul>';
console.log(html);
$('#contCnt').html(html);
$('ul#linkUl').listview();
}
},
function(tx, error) {
console.log(error.code);
var html = '<div id="errorDB">';
html += 'ERROR RETRIEVING FILES';
html += '</div>';
$('#contCnt').html(html);
}
);
});
});
$('div#content').live('pageshow', function(e) {
$('ul#linkUl').listview('refresh');
});
</script>
where the ContentPath variable is stored as a fileSystem object's directory.toUrl();
My fear is that jQueryMobile can't ajax-pull html from an external directory (the /Documents folder in iOS), or that I am missing some attribute or setting in order to do so.
Perhaps because I am using an absolute url? If so, how can I get the relative url from Phonegap's /www folder?
Do I have to declare something on the cordova.plist file?
Also, the downloaded content won't have to contain any js, they should be only plain html, but I need to keep jQuery Mobile header/footer and navigation system in all the pages.
I am using Cordova 2.2.0 and the latest releases of both jQuery and jQuery mobile.
Thanks in advance and sorry if something in the formatting goes wrong, I am new to SO (in case I'll edit asap).
You can open files from the documents folder (or any other folder the app has read access to).
There are two reasons that a link may not load as an ajax page
jQuery Mobile thinks that it isn't part of the app
There is a javascript error loading the page, which causes the default link click action to run instead of the ajax loader.
You could try using a call to $.mobile.changePage instead of just setting up the links - that gives you a little bit more visibility into what is going on.
I don't think a file url in a different folder should be treated as a different domain by jQuery Mobile, but to eliminate that possibility it should be reasonably easy to construct a relative url to the documents folder.
Solved, and thanks to Tom who led me through the right direction.
I guess the problem was that jQueryMobile was interpreting the absolute path as a an external link and thus the WebView was opening the html files as a new file, detaching it from the rest of the application.
What I did was substituting the absolute path file://localhost/var/mobile/Applications/APPID/Documents/subfolder
with a relative one, which in my case is './../../Documents/subfolder/filename.html
and now it works like a charm.