Error opening PowerPoint file using cfcontent - coldfusion

I can't seem to open a powerpoint(ppt) doc using cfcontent. My code has no problem opening other types of office docs. Below is the code:
<cfheader name="content-disposition" value="attachment; filename=#qry.clientFile#"/>
<cfcontent type="#qry.contentType#/#qry.contentSubType#" variable="#qry.documentData#"/>
qry.clientFile = Presentation2.ppt
qry.contentType = application
qry.contentSubType = vnd.ms-powerpoint
qry.documentData = the doc itself
I'm using the line above to open other doc no problem. Also, I'm trying to open a office 2003 ppt file in office 2007.

If you're just passing the name of the file as the variable argument that's incorrect. You need to provide a binary variable in the variable argument. If you just have the file on disk, then you need to use the file argument with a full drive path to the powerpoint file itself.
http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_c_11.html
<cfcontent type="#qry.contentType#/#qry.contentSubType#" file="#ExpandPath(qry.documentData)#">
Dan

Related

IgnoreReadOnlyRecommended not working from Python when opening Excel workbook

I have an excel workbook I need to open from python in a writable mode. The workbook is set up to have the prompt for a read only recommendation and this cannot be removed.
I am using the following:
import win32com.client
xl=win32com.client.Dispatch("Excel.Application")
filepath = 'C:\Users\FullFilePath.xlsm'
xl.Workbooks.Open(Filename=filepath, ReadOnly=False, IgnoreReadOnlyRecommended=True)
It opens the file, but it's still popping up the dialog asking if I want to open in read only. Is it possible to cancel that dialog?
Use instead:
xl = win32com.client.DispatchEx('Excel.Application')
This works without a dialog box for me.

Code to read the file and pass the bytes[]

So ColdFusion need to read the file and pass the bytes[].
once i read file using <cffile action="read"> then how to convert content to base64? i know there is function toBase64 but this takes string or binary data only.

Using Firefox website information in C++ program

I am trying to extract information from "about:plugins" website when you use Firefox web browser. I want to be able to use the contents of the website in my C++ program. Only way I know how to use content from another location is reading from a file.
What I am trying to do is read the file name and file path for each plugin from about:plugin'
Not sure if I could send this information to a file and then read it from there, but that seems like double work since if it output to file, I could just read it from there.
Needed to know how to extract information from the Firefox website in order to be used in a C++ program.
Just parse the pluginreg.dat file, you can find it in:
C:\Users\xxxxxxx\AppData\Roaming\Mozilla\Firefox\Profiles\xxxxxx.default
To obtain the AppData
char cAppData[MAX_PATH];
if(SHGetSpecialFolderPathA(NULL, cAppData, CSIDL_APPDATA, false))
{
// To obtain the profile name, parse the profiles.ini file in the folder
// ...AppData\Roaming\Mozilla\Firefox
// ...
}

determine file type c

I am trying to write a client/server program in C++ with Visual Studio 2008. So far the project runs does the following:
Run the webserver on cmd prompt - webserver 8080
open web browser - localhost 8080
to open local html file - localhost:8080/demo.html
But now... let's say the client requests for a gif file, then the server should send gif file.
client request for txt file, then the server should send .txt file. Similarly for .html and .xbm files.
I don't know how to do it.. Any help greatly appreciated.
On UNIX systems you'd use the file command: it uses a set of known "magic number" which are used to identify different file types. anda few heuristics to address the remaining files. Most file formats have some sort of identifier embedded, often in the first couple of bytes. Especially text files normally don't have a magic number but use only printable characters instead (with UTF8 and UTF16 being popular, classifying text files became a bit harder).
Once the file type is determined, you'd just set ghe corresponding HTTP header(s).
okay, because we're in the same class, I'll give you a clue :)
In the header part, put some if-else like this:
if(strcmp(type,"html")==0){
(void) sprintf(buff,"Content-Type:text/html\r\n");
(void) send(conn,buff,strlen(buff),0);
}
else if(strcmp(type,"gif")==0){
(void) sprintf(buff,"Content-Type:image/gif\r\n");
(void) send(conn,buff,strlen(buff),0);
}
Got it? And by the way, you need to get the extension (check path using endsWith function), compare the extension with file type then give out the right header. Test it with gif file :) I have it works already :) Going to submit now. Remember to vote up for me :)

Can thttpd support multipart/form-data?

I could successfully setup thttpd and tested a sample page with form. If I replace the input element with type "file" and post a file upload, thttpd closes the connection without any response but the same works if the input type is text.
So does thttpd supports file uploading ie handling of multipart/form-data? If yes how to handle the same using a cgi written in C/C++?