You are here

function plupload_file_uri_to_object in Plupload integration 7.2

Same name and namespace in other branches
  1. 7 plupload.module \plupload_file_uri_to_object()

Returns a file object which can be passed to file_save().

@todo Replace with calls to this function with file_uri_to_object() when http://drupal.org/node/685818 is fixed in core.

Parameters

string $uri: A string containing the URI, path, or filename.

Return value

boolean A file object, or FALSE on error.

2 calls to plupload_file_uri_to_object()
plupload_element_validate in ./plupload.module
Element validation handler for a Plupload element.
plupload_test_submit in ./plupload.module
Submit callback for plupload_test form.

File

./plupload.module, line 467
Implementation of plupload.module.

Code

function plupload_file_uri_to_object($uri) {
  global $user;
  $uri = file_stream_wrapper_uri_normalize($uri);
  $wrapper = file_stream_wrapper_get_instance_by_uri($uri);
  $file = new StdClass();
  $file->uid = $user->uid;
  $file->filename = drupal_basename($uri);
  $file->uri = $uri;
  $file->filemime = file_get_mimetype($uri);

  // This is gagged because some uris will not support it.
  $file->filesize = @filesize($uri);
  $file->timestamp = REQUEST_TIME;
  $file->status = FILE_STATUS_PERMANENT;
  return $file;
}