when uploading file from a mac (with both safari and firefox 3.0.5, Flash 10), the user receive a "403 access denied" error.

the debug output from the MAC:

---SWFUpload Instance Info---
Version: 2.2.0 Beta 3
Movie Name: SWFUpload_0
Settings:
    upload_url:               /swfupload
    flash_url:                /sites/all/modules/custom/swfupload/swfupload/swfupload.swf
    use_query_string:         false
    requeue_on_error:         false
    http_success:             
    file_post_name:           upload
    post_params:              [object Object]
    file_types:               *.jpg;*.jpeg;*.gif;*.png
    file_types_description:   
    file_size_limit:          5242880
    file_upload_limit:        200
    file_queue_limit:         200
    debug:                    true
    prevent_swf_caching:      true
    button_placeholder_id:    upload-swfwrapper
    button_image_url:         
    button_width:             120
    button_height:            15
    button_text:              
    button_text_style:        color: #000000; font-size: 16pt;
    button_text_top_padding:  0
    button_text_left_padding: 0
    button_action:            -110
    button_disabled:          false
    custom_settings:          [object Object]
Event Handlers:
    swfupload_loaded_handler assigned:  true
    file_dialog_start_handler assigned: false
    file_queued_handler assigned:       true
    file_queue_error_handler assigned:  true
    upload_start_handler assigned:      true
    upload_progress_handler assigned:   true
    upload_error_handler assigned:      true
    upload_success_handler assigned:    true
    upload_complete_handler assigned:   true
    debug_handler assigned:             true

SWFUpload.SWFObject Plugin settings:
    minimum_flash_version:                      9.0.28
    swfupload_pre_load_handler assigned:     false
    swfupload_load_failed_handler assigned:     false

SWF DEBUG: SWFUpload Init Complete
SWF DEBUG: 
SWF DEBUG: ----- SWF DEBUG OUTPUT ----
SWF DEBUG: Build Number:           SWFUPLOAD 2.2.0 Beta 3 2008-12-05
SWF DEBUG: movieName:              SWFUpload_0
SWF DEBUG: Upload URL:             /swfupload
SWF DEBUG: File Types String:      *.jpg;*.jpeg;*.gif;*.png
SWF DEBUG: Parsed File Types:      jpg,jpeg,gif,png
SWF DEBUG: HTTP Success:           0
SWF DEBUG: File Types Description:  (*.jpg;*.jpeg;*.gif;*.png)
SWF DEBUG: File Size Limit:        5368709120 bytes
SWF DEBUG: File Upload Limit:      200
SWF DEBUG: File Queue Limit:       200
SWF DEBUG: Post Params:
SWF DEBUG:                         has_js=1
SWF DEBUG:                         node_settings={ "filepath": "%file_directory_path/users/%user_id/%pellicule_id", "max_img_resolution": "1280x1024", "list": 1, "file_extensions": "jpg jpeg gif png", "max_file_size": 5242880, "node_max_file_size": 0, "max_files": "200", "upload_usersize": 104857600 }
SWF DEBUG:                         CFGLOBALS=urltoken%3DCFID%23%3D66631%26CFTOKEN%23%3D72727148%26jsessionid%23%3Df030d902e61e1954f31a630522d063a52670%23lastvisit%3D%7Bts%20%272008%2D06%2D30%2009%3A43%3A16%27%7D%23timecreated%3D%7Bts%20%272008%2D06%2D23%2014%3A07%3A32%27%7D%23hitcount%3D129%23cftoken%3D72727148%23cfid%3D66631%23
SWF DEBUG:                         CFID=66631
SWF DEBUG:                         style=neutre
SWF DEBUG:                         max_img_resolution=1280x1024
SWF DEBUG:                         SESS4fd5524dbd5af202aa213bb41e83b1f4=7f41959e27cb3fe74831ffb2dc9c62a5
SWF DEBUG:                         op=move_uploaded_file
SWF DEBUG:                         instance={ "name": "upload" }
SWF DEBUG:                         CFTOKEN=72727148
SWF DEBUG:                         sid=33352a3132613564316265623435363331616666643534613261303038636261343531
SWF DEBUG:                         filepath=sites/default/files/users/35/1/
SWF DEBUG: ----- END SWF DEBUG OUTPUT ----
SWF DEBUG: 
SWF DEBUG: Event: fileDialogStart : Browsing files. Multi Select. Allowed file types: *.jpg;*.jpeg;*.gif;*.png
SWF DEBUG: Select Handler: Received the files selected from the dialog. Processing the file list...
SWF DEBUG: Event: fileQueued : File ID: SWFUpload_0_0
SWF DEBUG: Event: fileDialogComplete : Finished processing selected files. Files selected: 1. Files Queued: 1
SWF DEBUG: StartUpload: First file in queue
SWF DEBUG: Event: uploadStart : File ID: SWFUpload_0_0
SWF DEBUG: Global Post Item: has_js=1
SWF DEBUG: Global Post Item: node_settings={ "filepath": "%file_directory_path/users/%user_id/%pellicule_id", "max_img_resolution": "1280x1024", "list": 1, "file_extensions": "jpg jpeg gif png", "max_file_size": 5242880, "node_max_file_size": 0, "max_files": "200", "upload_usersize": 104857600 }
SWF DEBUG: Global Post Item: CFGLOBALS=urltoken%3DCFID%23%3D66631%26CFTOKEN%23%3D72727148%26jsessionid%23%3Df030d902e61e1954f31a630522d063a52670%23lastvisit%3D%7Bts%20%272008%2D06%2D30%2009%3A43%3A16%27%7D%23timecreated%3D%7Bts%20%272008%2D06%2D23%2014%3A07%3A32%27%7D%23hitcount%3D129%23cftoken%3D72727148%23cfid%3D66631%23
SWF DEBUG: Global Post Item: CFID=66631
SWF DEBUG: Global Post Item: style=neutre
SWF DEBUG: Global Post Item: max_img_resolution=1280x1024
SWF DEBUG: Global Post Item: SESS4fd5524dbd5af202aa213bb41e83b1f4=7f41959e27cb3fe74831ffb2dc9c62a5
SWF DEBUG: Global Post Item: op=move_uploaded_file
SWF DEBUG: Global Post Item: instance={ "name": "upload" }
SWF DEBUG: Global Post Item: CFTOKEN=72727148
SWF DEBUG: Global Post Item: sid=33352a3132613564316265623435363331616666643534613261303038636261343531
SWF DEBUG: Global Post Item: filepath=sites/default/files/users/35/1/
SWF DEBUG: ReturnUploadStart(): File accepted by startUpload event and readied for upload.  Starting upload to /swfupload for File ID: SWFUpload_0_0
SWF DEBUG: Event: uploadProgress (OPEN): File ID: SWFUpload_0_0
SWF DEBUG: Event: uploadError: HTTP ERROR : File ID: SWFUpload_0_0. HTTP Status: 403.
SWF DEBUG: Event: uploadComplete : Upload cycle complete.
SWF DEBUG: StartUpload: First file in queue
SWF DEBUG: StartUpload(): No files found in the queue.

the debug output from the Windows XP

---SWFUpload Instance Info---
Version: 2.2.0 Beta 3
Movie Name: SWFUpload_0
Settings:
	upload_url:               /swfupload
	flash_url:               
/sites/all/modules/custom/swfupload/swfupload/swfupload.swf
	use_query_string:         false
	requeue_on_error:         false
	http_success:             
	file_post_name:           upload
	post_params:              [object Object]
	file_types:               *.jpg;*.jpeg;*.gif;*.png
	file_types_description:   
	file_size_limit:          5242880
	file_upload_limit:        200
	file_queue_limit:         200
	debug:                    true
	prevent_swf_caching:      true
	button_placeholder_id:    upload-swfwrapper
	button_image_url:         
	button_width:             124
	button_height:            15
	button_text:              
	button_text_style:        color: #000000; font-size: 16pt;
	button_text_top_padding:  0
	button_text_left_padding: 0
	button_action:            -110
	button_disabled:          false
	custom_settings:          [object Object]
Event Handlers:
	swfupload_loaded_handler assigned:  true
	file_dialog_start_handler assigned: false
	file_queued_handler assigned:       true
	file_queue_error_handler assigned:  true
	upload_start_handler assigned:      true
	upload_progress_handler assigned:   true
	upload_error_handler assigned:      true
	upload_success_handler assigned:    true
	upload_complete_handler assigned:   true
	debug_handler assigned:             true

SWFUpload.SWFObject Plugin settings:
	minimum_flash_version:                      9.0.28
	swfupload_pre_load_handler assigned:     false
	swfupload_load_failed_handler assigned:     false

SWF DEBUG: SWFUpload Init Complete
SWF DEBUG: 
SWF DEBUG: ----- SWF DEBUG OUTPUT ----
SWF DEBUG: Build Number:           SWFUPLOAD 2.2.0 Beta 3 2008-12-05
SWF DEBUG: movieName:              SWFUpload_0
SWF DEBUG: Upload URL:             /swfupload
SWF DEBUG: File Types String:      *.jpg;*.jpeg;*.gif;*.png
SWF DEBUG: Parsed File Types:      jpg,jpeg,gif,png
SWF DEBUG: HTTP Success:           0
SWF DEBUG: File Types Description:  (*.jpg;*.jpeg;*.gif;*.png)
SWF DEBUG: File Size Limit:        5368709120 bytes
SWF DEBUG: File Upload Limit:      200
SWF DEBUG: File Queue Limit:       200
SWF DEBUG: Post Params:
SWF DEBUG:                        
SESSda0eb4cde2b8c818be27bc2b7d299760=95a2a43af826f4d2f7477a7b665a046c
SWF DEBUG:                         style=sanguine
SWF DEBUG:                         has_js=1
SWF DEBUG:                         max_img_resolution=1280x1024
SWF DEBUG:                         op=move_uploaded_file
SWF DEBUG:                         instance={ "name": "upload" }
SWF DEBUG:                         ZDEDebuggerPresent=php,phtml,php3
SWF DEBUG:                        
sid=332a3131306266623538633464336162623439653634396261383135643362363735
SWF DEBUG:                         filepath=sites/default/files/users/3/6/
SWF DEBUG:                         node_settings={ "filepath":
"%file_directory_path/users/%user_id/%pellicule_id", "max_img_resolution":
"1280x1024", "list": 1, "file_extensions": "jpg jpeg gif png",
"max_file_size": 5242880, "node_max_file_size": 0, "max_files": "200",
"upload_usersize": 104857600 }
SWF DEBUG: ----- END SWF DEBUG OUTPUT ----
SWF DEBUG: 
SWF DEBUG: Event: fileDialogStart : Browsing files. Multi Select. Allowed
file types: *.jpg;*.jpeg;*.gif;*.png
SWF DEBUG: Select Handler: Received the files selected from the dialog.
Processing the file list...
SWF DEBUG: Event: fileQueued : File ID: SWFUpload_0_0
SWF DEBUG: Event: fileDialogComplete : Finished processing selected files.
Files selected: 1. Files Queued: 1
SWF DEBUG: StartUpload: First file in queue
SWF DEBUG: Event: uploadStart : File ID: SWFUpload_0_0
SWF DEBUG: Global Post Item:
SESSda0eb4cde2b8c818be27bc2b7d299760=95a2a43af826f4d2f7477a7b665a046c
SWF DEBUG: Global Post Item: style=sanguine
SWF DEBUG: Global Post Item: has_js=1
SWF DEBUG: Global Post Item: max_img_resolution=1280x1024
SWF DEBUG: Global Post Item: op=move_uploaded_file
SWF DEBUG: Global Post Item: instance={ "name": "upload" }
SWF DEBUG: Global Post Item: ZDEDebuggerPresent=php,phtml,php3
SWF DEBUG: Global Post Item:
sid=332a3131306266623538633464336162623439653634396261383135643362363735
SWF DEBUG: Global Post Item: filepath=sites/default/files/users/3/6/
SWF DEBUG: Global Post Item: node_settings={ "filepath":
"%file_directory_path/users/%user_id/%pellicule_id", "max_img_resolution":
"1280x1024", "list": 1, "file_extensions": "jpg jpeg gif png",
"max_file_size": 5242880, "node_max_file_size": 0, "max_files": "200",
"upload_usersize": 104857600 }
SWF DEBUG: ReturnUploadStart(): File accepted by startUpload event and
readied for upload.  Starting upload to /swfupload for File ID: SWFUpload_0_0
SWF DEBUG: Event: uploadProgress (OPEN): File ID: SWFUpload_0_0
SWF DEBUG: Event: uploadProgress: File ID: SWFUpload_0_0. Bytes: 32768.
Total: 51223
SWF DEBUG: Event: uploadProgress: File ID: SWFUpload_0_0. Bytes: 51223.
Total: 51223
SWF DEBUG: Event: uploadSuccess: File ID: SWFUpload_0_0 Data: { "op":
"upload_complete", "file": { "filename": "avatar.jpg", "filepath":
"sites/default/files/users/3/6/avatar.jpg", "filemime": "image/jpeg",
"source": "upload", "destination":
"sites/default/files/users/3/6/avatar.jpg", "filesize": 51223, "uid": "3",
"status": 0, "timestamp": 1231408648, "fid": "778" }, "filepath":
"sites/default/files/users/3/6/", "instance": { "name": "upload" },
"node_settings": { "filepath":
"%file_directory_path/users/%user_id/%pellicule_id", "max_img_resolution":
"1280x1024", "list": 1, "file_extensions": "jpg jpeg gif png",
"max_file_size": 5242880, "node_max_file_size": 0, "max_files": "200",
"upload_usersize": 104857600 }, "messages": [  ] }
SWF DEBUG: Event: uploadComplete : Upload cycle complete.
SWF DEBUG: StartUpload: First file in queue
SWF DEBUG: StartUpload(): No files found in the queue.
CommentFileSizeAuthor
#7 swfupload-355966.patch580 bytesskilip
#6 swfupload-355966.patch580 bytesskilip

Comments

skilip’s picture

This is really weird, since I've developed the whole module on a Mac. Are you sure you're running Flash player 10 on both machines?

fabien1979’s picture

Yes, I use the latest version of Flash 10 on both machines (10.0 r12).

skilip’s picture

And are you testing this on the same server?

fabien1979’s picture

Yes, it's the same server.
But I found a workaround...

I modified the swfupload_access() as followed:

function swfupload_access() {
  $result = FALSE;
  $p = (object) $_POST;
  // Validate the request
  if($p->sid) {
    $sid = split("\*", hex2bin($p->sid));
    global $user;
    $user->uid = $sid[0];
    $user = user_load($user->uid);
    if (!user_access('upload files', $user)) {
		return FALSE;
	}
		
    if (!$user->uid) {
      return ($sid[1] == md5($_SERVER['REMOTE_ADDR']));
    }
    $result = db_query("SELECT sid FROM {sessions} WHERE uid = %d", $sid[0]);
    while ($row = db_fetch_object($result)) {
      $valid_sids[] = md5($row->sid);
    }

    if (in_array($sid[1], $valid_sids)) {
  		return TRUE;
    }
    
    // The sid doesn't exist for this user.
    return FALSE;
  }
  // No session ID is set, we can assume we're still in the same session
  return (($p->op) && user_access('upload files'));
}

As you can see, I reload the $user variable with the user_load() method to be sure that the roles array is correctly loaded into the $user class.
And to be sure that the user_access() method checks the good account, I pass the $user variable to the user_access() method.

skilip’s picture

I get it. The user object loaded in user_access is probably an anonymous user. When you overwrite the (global) user object with user_load(), do you still need to pass the user object as an argument to user_access()?

Thanks for reporting!

skilip’s picture

StatusFileSize
new580 bytes
skilip’s picture

Status: Active » Patch (to be ported)
StatusFileSize
new580 bytes
skilip’s picture

Status: Patch (to be ported) » Fixed

committed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.