View Single Post
Old 12-12-2011, 01:44 PM   PM User | #1
roher4
New Coder

 
Join Date: Jul 2010
Location: Canada
Posts: 26
Thanks: 2
Thanked 0 Times in 0 Posts
roher4 is an unknown quantity at this point
Converting PHP to Rails

Hi,

How would I go about converting this PHP into RoR? I'm just starting out and am a little confused.

Here's the code I want to convert:
Code:
<?php  
$file_name = substr ( md5(uniqid(rand(),1)), 5, 15); 
$uploaddir = './uploads/';
$file = basename($_FILES['userfile']['name']);
$newname = $file_name . $file;
$uploadfile = $uploaddir . $newname;
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {        
$imagepath =  http://example.com/uploads/{$newname};
}
print $imagepath;?>
roher4 is offline   Reply With Quote