Monday, September 17, 2007

Settings to charge for large file uploads via PHP

In php.ini (should research whether these can be set in script instead):

upload_max_filesize
memory_limit
post_max_size
max_input_time

In upload script:

set_time_limit(0)

In upload form:



Docs here.

Thursday, August 30, 2007

REST Urls in Rails

A helpful overview of Rails' REST Url convention:

/airports/ + POST = create
/airports/1 + GET = show
/airports/1 + PUT = update
/airports/1 + DELETE = destroy
/airports/ + GET = index
/airports/new + GET = new
/airports/1;edit + GET = edit

From http://softiesonrails.com/2007/4/18/rest-101-part-4-routing

Tuesday, August 21, 2007

Javascript module pattern

A handy javascript pattern from Christian Heilmann (http://www.wait-till-i.com/index.php?p=476):


var revealingModulePattern = function(){
var privateVar = 1;

function privateFunction(){
alert('private');
};

var publicVar = 2;

function publicFunction(){
anotherPublicFunction();
};

function anotherPublicFunction(){
privateFunction();
};

function getCurrentState(){
return 2;
};

// reveal all things private by assigning public pointers
return {
init:publicFunction,
count:publicVar,
increase:anotherPublicFunction,
current:getCurrentState()
}
}();

alert(revealingModulePattern.current) // => 2
revealingModulePattern.init();

Tuesday, January 16, 2007

Random Microsoft Reporting Services failure

I have a web app which prints Reporting Services reports on demand without displaying them (using LocalReports). It has worked for months but started failing the other day with this exception:

System.MissingMethodException: Method not found: 'Void Microsoft.Reporting.PreviewItemContext.SetPath(System.String, System.String, Microsoft.Reporting.DefinitionSource, System.Reflection.Assembly)'. at Microsoft.Reporting.WebForms.LocalReport.CreateItemContext() at Microsoft.Reporting.WebForms.LocalReport.CompileReport() at Microsoft.Reporting.WebForms.LocalReport.InternalRender(String format, Boolean allowInternalRenderers, String deviceInfo, CreateAndRegisterStream createStreamCallback, Warning[]& warnings) at Microsoft.Reporting.WebForms.LocalReport.Render(String format, String deviceInfo, CreateStreamCallback createStream, Warning[]& warnings) at PipelineWeb.ReportManager.Export(LocalReport report) at PipelineWeb.DispatchService.PrintShippingReport(String SalesOrderNumber, DateTime TransactionDate)

It still works on my development machine. I'm stumped so far.

Update: Thanks to a helpful MS employee on the forums, this issue has been resolved. It had to do with conflicting ReportViewer dlls following the VS SP1 update. Details here -http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1131480&SiteID=1

Tuesday, December 05, 2006

Can't touch file upload elements with javascript

Son of a %#@%$. I was in the process of adding a slick feature to a complicated HTML form and ran into an unexpected problem.

The "form" has some input elements outside the actual <form> tag. The values from these elements are packaged up a certain way and injected into a hidden text field during the form submit process. Works like a charm.

I wanted to add the ability to upload files using this same basic mechanism -- create an <input type="file"> element inside the <form> based on info entered outside the form. It turns out that this isn't possible because the browser won't allow programmatic manipulation of file upload elements. Now that I think about it, the reason for this is painfully obvious.

I also tried moving the DOM node from its original location to a location inside the <form> (the data attached to the node was still entered by the user). No dice on that either.

Crap.