diff --git a/sites/all/modules/webform/includes/webform.submissions.inc b/sites/all/modules/webform/includes/webform.submissions.inc
index 86b00c6..755e5fc 100644
--- a/sites/all/modules/webform/includes/webform.submissions.inc
+++ b/sites/all/modules/webform/includes/webform.submissions.inc
@@ -129,6 +129,7 @@ function webform_submission_insert($node, $submission) {
           'cid' => $cid,
           'no' => $delta,
           'data' => is_null($value) ? '' : $value,
+          'data_int' => (string) (int) $value === $value ? (int) $value : 0,
         ))
         ->execute();
     }
diff --git a/sites/all/modules/webform/webform.install b/sites/all/modules/webform/webform.install
index 4d79f1a..153d677 100644
--- a/sites/all/modules/webform/webform.install
+++ b/sites/all/modules/webform/webform.install
@@ -351,6 +351,12 @@ function webform_schema() {
         'size' => 'medium',
         'not null' => TRUE,
       ),
+      'data_int' => array(
+        'description' => 'The integer value of the submitted value of this field.',
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0,
+      ),
     ),
     'primary key' => array('nid', 'sid', 'cid', 'no'),
     'indexes' => array(
@@ -609,3 +615,17 @@ function webform_update_7313() {
     }
   }
 }
+
+/**
+ * Populate data_int as best as we can.
+ */
+function webform_update_7314() {
+  db_add_field('webform_submitted_data', 'data_int', array(
+        'description' => 'The integer value of the submitted value of this field.',
+        'type' => 'int',
+        'not null' => TRUE,
+        'default' => 0,
+      )
+  );
+  db_query('UPDATE {webform_submitted_data} SET data_int = CAST(data AS :mysql_sucks)', array(':mysql_sucks' => Database::getConnection()->databaseType() == 'mysql' ? 'SIGNED INTEGER' : 'INT'));
+}
diff --git a/sites/all/modules/webform/webform.module b/sites/all/modules/webform/webform.module
index 604cbce..adc6b85 100644
--- a/sites/all/modules/webform/webform.module
+++ b/sites/all/modules/webform/webform.module
@@ -896,7 +896,7 @@ function webform_file_download($uri) {
 
   // Determine whether this file was a webform upload. If it was, retrieve file
   // information, plus the user id of the uploader.
-  $file = db_query("SELECT ws.uid, f.* FROM {file_managed} f INNER JOIN {webform_submitted_data} wsd ON f.fid = wsd.data INNER JOIN {webform_submissions} ws ON ws.sid = wsd.sid WHERE f.uri = :uri", array('uri' => $uri))->fetchObject();
+  $file = db_query("SELECT ws.uid, f.* FROM {file_managed} f INNER JOIN {webform_submitted_data} wsd ON f.fid = wsd.data_int INNER JOIN {webform_submissions} ws ON ws.sid = wsd.sid INNER JOIN {webform_component} wc ON wc.cid = wsd.cid  WHERE f.uri = :uri AND wc.type = :file", array('uri' => $uri, ':file' => 'file'))->fetchObject();
   if ($file) {
     // Allow file access for admins, or for users who are viewing their own
     // submissions.
