Connecting Tech Pros Worldwide Help | Site Map

Converting a Few lines of File Upload Code from PHP to Coldfusion

Newbie
 
Join Date: Feb 2007
Posts: 2
#1: Feb 23 '07
Can someone help me convert the PHP lines below from PHP to Coldfusion?

[PHP]<?php
$ftmp = $_FILES['image']['tmp_name'];
$oname = $_FILES['image']['name'];
$fname = 'upload/'.$_FILES['image']['name'];
if(move_uploaded_file($ftmp, $fname)){
?>
<html><head><script>
var par = window.parent.document;
var images = par.getElementById('images');
var imgdiv = images.getElementsByTagName('div')[<?=(int)$_POST['imgnum']?>];
var image = imgdiv.getElementsByTagName('img')[0];
imgdiv.removeChild(image);
var image_new = par.createElement('img');
image_new.src = 'resize.php?pic=<?=$oname?>';
image_new.className = 'loaded';
imgdiv.appendChild(image_new);
</script></head>
</html>
<?php
exit();
}
?><html><head>[/PHP]
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#2: Feb 23 '07

re: Converting a Few lines of File Upload Code from PHP to Coldfusion


You'll have to explain what $_FILES is:
[PHP]$ftmp = $_FILES['image']['tmp_name'];
$oname = $_FILES['image']['name'];
$fname = 'upload/'.$_FILES['image']['name'];
if(move_uploaded_file($ftmp, $fname)){[/PHP]
See the Upload Tutorial (not complete yet).
Just one tag <cffile action="upload" ...> should perform the upload. Then you can move the file to the desired location using cffile action="move".
Reply