main = runApp defaultConfig $ do
  upload <- remote $ \name file -> do
    filedata <- getBlobData file
    liftIO $ BS.writeFile name (toByteString filedata)

  runClient $ withElems ["file","upload"] $ \[file,btn] -> do
    btn `onEvent` Click $ \_ -> do
      mfd <- getFileData file 0
      case mfd of
        Just fd -> do
          fn <- getFileName file
          onServer $ upload <.> fn <.> fd
          alert "File uploaded!"
        _ -> do
          alert "You need to specify a file first."
    return ()
main = runApp defaultConfig $ do
  upload <- remote $ \name file -> do
    filedata <- getBlobData file
    liftIO $ BS.writeFile name (toByteString filedata)

  runClient $ withElems ["file","upload"] $ \[file,btn] -> do
    btn `onEvent` Click $ \_ -> do
      mfd <- getFileData file 0
      case mfd of
        Just fd -> do
          fn <- getFileName file
          onServer $ upload <.> fn <.> fd
          alert "File uploaded!"
        _ -> do
          alert "You need to specify a file first."
    return ()
main = runApp defaultConfig $ do
  upload <- remote $ \name file -> do
    filedata <- getBlobData file
    liftIO $ BS.writeFile name (toByteString filedata)

  runClient $ withElems ["file","upload"] $ \[file,btn] -> do
    btn `onEvent` Click $ \_ -> do
      mfd <- getFileData file 0
      case mfd of
        Just fd -> do
          fn <- getFileName file
          onServer $ upload <.> fn <.> fd
          alert "File uploaded!"
        _ -> do
          alert "You need to specify a file first."
    return ()