diff --git a/resources/file_resource.inc b/resources/file_resource.inc
index fa75855..23d9386 100644
--- a/resources/file_resource.inc
+++ b/resources/file_resource.inc
@@ -163,7 +163,7 @@ function _file_resource_create($file) {
   if (isset($file->filename) && !isset($file->filepath)) {
     $file->filepath = file_default_scheme() . '://' . $file->filename;
   }
-  $dir = file_default_scheme() . '://';
+  $dir = drupal_dirname($file->filepath);
   // Build the destination folder tree if it doesn't already exists.
   if (!file_prepare_directory($dir, FILE_CREATE_DIRECTORY)) {
     return services_error(t("Could not create destination directory for file."), 500);
@@ -319,7 +319,7 @@ function _file_resource_index($page, $fields, $parameters, $page_size) {
 function _file_resource_access($op = 'view', $args = array()) {
   // Adds backwards compatability with regression fixed in #1083242
   if (isset($args[0])) {
-    $args[0] = _services_access_value($args[0], 'file'); 
+    $args[0] = _services_access_value($args[0], 'file');
   }
 
   global $user;
diff --git a/tests/functional/ServicesResourceFileTests.test b/tests/functional/ServicesResourceFileTests.test
index e474e6a..f45c1dc 100644
--- a/tests/functional/ServicesResourceFileTests.test
+++ b/tests/functional/ServicesResourceFileTests.test
@@ -95,9 +95,11 @@ class ServicesResourceFileTests extends ServicesWebTestCase {
    */
   public function testResourceFileCreate() {
     // Create file argument with data.
+    $filepath = file_default_scheme() . '://' . rand() . '/' . rand() . '/' . $this->testfile->filename;
     $file = array(
       'filesize' => filesize($this->testfile->uri),
       'filename' => $this->testfile->filename,
+      'filepath' => $filepath,
       'file' => base64_encode(file_get_contents($this->testfile->uri)),
       'uid' => $this->privileged_user->uid,
     );
@@ -109,6 +111,7 @@ class ServicesResourceFileTests extends ServicesWebTestCase {
     // Load file and assert that it exists.
     $file_load = file_load($result['body']['fid']);
     $this->assertTrue(is_file($file_load->uri), t('New file saved to disk.'), 'FileResource: Create');
+    $this->assertEqual($file_load->uri, $filepath, t('The path of newly created file placed into directory with random name.'), 'FileResource: Create');
   }
   /**
    * Test create_raw method.
