View Full Version : ColdFusion to php help

02-09-2010, 11:03 PM
Can anybody translate this into php? I haven't the first clue how to approach this.

<cfset x = GetHttpRequestData()>
<cfset startBase64 = findNoCase('base64', x.content) />
<cfset base64content = mid(x.content,startBase64+7, len(x.content)) />

<cfset UseFileName = GetDirectoryFromPath(GetCurrentTemplatePath()) & "shots\pastedImage" & DateFormat(Now(), "mmddyyyy") & TimeFormat(Now(), "hhmmss") & ".jpg" />
<cffile action="write" file="#UseFileName#" output="#ToBinary(base64content)#" />
<cfset session.UseFileName = UseFileName>


02-10-2010, 03:36 AM
Well something like this looks kinda right

session_start(); // Start the session
$base64content = $_POST['base64']; // This may be $_GET instead of $_POST
$dir = '/path/to/shots/folder/'; // Set folder for image to be written to
$_SESSION['UseFileName'] = $dir.date('his').'.jpg'; // Assign full file path to session
file_put_contents($_SESSION['UseFileName'], $base64content); // Write content to file
echo urlencode($_SESSION['UseFileName']; // Echo file path

02-10-2010, 02:12 PM
Great, I will see how it works. Thanks