I want to expose a method which will accept a file POSTed to it and
save the file to the database.  I have found php examples all over the
place (one below).

How do i do this in web2py?  I don't want to use a form as I don't
want to upload interactively.

My model is this:
db.define_table('uploadedFiles',
                Field('displayName'),
                Field('store_file','upload',autodelete=True))


Thanks in advance

Brendan


Example php:
<input type="submit" value="Upload File" />
</form>
<?php
  $to_file = "tmp/" . basename($_FILES['uploadedfile']['name']);
  $from_file = $_FILES['uploadedfile']['tmp_name'];

  if (move_uploaded_file($from_file, $to_file)) {
    echo "Successful upload";
?>
  <a href="<?php echo $to_file;?>"><?php echo $to_file;?></a>
<?php
  } else {
    echo "Unsuccessful upload";
  }
?>

Reply via email to