Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jul 2010
    Location
    Canada
    Posts
    26
    Thanks
    2
    Thanked 0 Times in 0 Posts

    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;?>

  • #2
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Looks like a file upload, you can start by looking at the gems: carrier wave, paperclip.

    I could teach you to do it manually, but your code will suck compared to theirs.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •