Link to home
Start Free TrialLog in
Avatar of bcombe
bcombe

asked on

Path issue with Flash src

I have a page called FlashFrame.aspx  where I have the html wrapper on the flash JS code.

The flash file will load fine when I place it in the same folder that this page FlashFrame.aspx is on but the files are in sub-directories in a different folder called App_data.

Normally with relative paths we use something like "../folder/subfolder/file.swf" for hyperlinks or whatever.

  If I put the files as sub-folders in the path where my FlashFrame.aspx page is it works too.
Its the little dot dots ".." that don't seem to be consumed right.

I tried putting a copy of my aspx file in the App_Data folder and redirecting to it but got a for 'Forbidden' error - guess theres a reason for that - the other thing is to put all the swf files in/under the path where the folder of the FlashFrame.aspx is but I know thats not the real answer. I have used UrlEncode but I that doesn't seem to help.

Basically -
Im having trouble supplying the URL parameter to the   '<param name="movie" value="'+url+'"  from  var url= blah    for reasons I explain below:

 I have as aspx page where I declare a public variable

Public FF_SWF_URL As String

And later I use it  to construct the path where the file lives  the file info is obtained from session variables from a data tables on click event

Dim FF_SWF_Case As String = Me.Page.Session("SWF_Case").ToString
Dim FF_SWF_Firm As String = Me.Page.Session("SWF_Firm").ToString
Dim FF_SWF_DocFileName As String = Me.Page.Session("SWF_DocFileName").ToString()
dataFilePath = Me.Page.Server.MapPath("..\App_Data\loadedfiles\") + FF_SWF_Case + "\" + FF_SWF_Firm + "\"

If the file exists I tried using the URL encode after having an issue

Dim fileExists As Boolean = System.IO.File.Exists(dataFilePath + FF_SWF_DocFileName)
If fileExists Then
FF_SWF_URL = dataFilePath + FF_SWF_DocFileName
FF_SWF_URL = Me.Server.UrlEncode(dataFilePath + FF_SWF_DocFileName)
Else
Utils.MiscUtils.RegisterJScriptAlert(Me, "FILE_NOT_FOUND", "File cannot be found to download")
End If

Using an alert I can prove the text gets to the .aspx page but without any encoding all the \ slash characters drop out!

var url= '<%=FF_SWF_URL%>'
 alert("ASPX says : " + '<%=FF_SWF_URL%>')

Avatar of bcombe
bcombe

ASKER

FYI - the single quote above was replaced by a strange character - that line is commented out
Avatar of bcombe

ASKER

Seems like the issue is actually about permissions with the App-Data folder itself as I can access the files almost anywhere else.
The App_Data folder is reserved and is treated specially by the ASP.NET environment and compiler, It should not contain anything else then classes, and it must not be called directly from a browser or other client (the src for your flash movie is a url that's called by the browser).

This is a security measure and you really should keep it like that, because if you loosen this security restriction you make it possible for anybody to reverse engineer your website (or at least parts of it), which is a giant / huge / enormous security risk.

To solve your problem, do as you already suggested: place the flash sources in a "normal" subdirectory. Most projects have a directory called "resources" right under the root, under which they place the "css", "javascript" and "flash" resources.

-- Abel --
Avatar of bcombe

ASKER

I learned this Abel, just in days last. A consultant had 'recommended' putting the files in there to protect them from access except by code. I understand now. My issue is the url encoding for swf parameters - it seems to be different from what normal url encoding offers - is that true ?
That consultant has indeed given you wrong information. The App_Data should never be used for this. Glad you seconded that :)

No, it is not different from what normal url encoding offers, but url encoding is often misunderstood and wrongly applied. It also depends a bit on how your SWF expects the data. Can you show the exact string as it is in the src parameter in your rendered page? I may pinpoint errors in the url encoding.
Avatar of bcombe

ASKER

Sure, let me say that the images are now located in the path here:

C:\web\vioxxcost\documentfile\docfiles\

The aspx page that has the JS flash stuff is here:

C:\web\vioxxcost\documentfile\FlashFrame.aspx

The path comes from the codebehind, I have:

var swf_url = "<%FF_SWF_URL%>'

and then later on I use the swf_url in the  embed src  and the param name stuff.

The path I send in is

dataFilePath = "DocFiles\" + FF_SWFCase + "/" FF_SWF_Firm + "/"
FF_SWF_URL = me.server.urlencode(dataFilePath + FF_SWF_DocFileName)

and I also tried

dataFilePath = me.page.Server.MapPath("DocFiles\") + FF_SWFCase + "\" FF_SWF_Firm + "\"

which *works* actually with this line:

dim fileExists as Boolean - system.IO.file.exists(datafilePath +  FF_SWF_DocFileName)

meaning it finds the file if it exists and sets fileExists true.

So all of the above works on the local machine - but when I deploy to the live server the relative path is the same from the site root down. Instead of showing the flash file in the FlashFrame.aspx  page its blank - if I right click I see the Adobe Flash context menu though.



I may have misunderstood, but are you trying to say that you send a local path as the src parameter for an HTML page? Because that will not work (you need a relative or absolute url instead).

I actually meant you to paste in the rendered HTML, i.e. what you see in the browser, and then the part which shows the bit with the src attribute. Can you show that? It will clear up a whole lot of things
Avatar of bcombe

ASKER

Ah Ok - I will - its on a different computer.  To answer you Im using the local path just to confirm the file exists and using a relative path for the src - like this:

dataFilePath = "DocFiles/" + FF_SWFCase + "/" FF_SWF_Firm + "/"
FF_SWF_URL = me.server.urlencode(dataFilePath + FF_SWF_DocFileName)

- give me a bit and I'll paste in the code
Avatar of bcombe

ASKER

Sorry that took so long - I had a detour. Here is what is in view source.

 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1"><title>
 
</title>
    <style type="text/css">
        .SWF_tablestyle
        {
            width: 100%;
            height: 100%;
            background-color: #ffffff;
        }
    </style>
    <link rel="stylesheet" rev="stylesheet" type="text/css" href="../Styles/BaseStyles.css" /><link rel="stylesheet" rev="stylesheet" type="text/css" href="../Styles/Styles.css" /></head>
    
    <body id="Body1" class="pBack">
    
    <form name="Form1" method="post" action="FlashFrame.aspx" id="Form1">
 
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUINjQ3Njg4NjAPFCsAA2RoZGRkbz0js890UKI6bYnpmBkVHlp9fxw=" />
</div>
 
<script language="javascript"  type="text/javascript" src="/ApplicationWebForm.js"></script><script language="javascript"  type="text/javascript" src="/ApplicationWebUIValidation.js"></script>
    
 
 
                        
                        
                        
<table class="SWF_tablestyle">
    <tr>
        <td style="padding: 1px; font-family: Arial, Helvetica, sans-serif; color: #000000; vertical-align: 65%; text-align: left; font-variant: normal; clear: none; font-size: small;" 
            valign="baseline" align="left"  colspan="3" bgcolor="White">
            <div>
                    <div style="float: right; width: 80%; background-color: #33CCCC;"></div>
 
                </div>
        </td>
    </tr>
    <tr>
        <td ></td>
        <td>
<div id="FlashContainer">
 
<script language="JavaScript1.1" type="text/javascript">
 <!-- 
 var requiredMajorVersion = 7;
 var requiredMinorVersion = 0;
 var requiredRevision = 0;
 
 var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
 var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
 
 function JSGetSwfVer(i){
             if (navigator.plugins != null && navigator.plugins.length > 0) {
                         if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
                                    var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
                         var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
                                    descArray = flashDescription.split(" ");
                                    tempArrayMajor = descArray[2].split(".");
                                    versionMajor = tempArrayMajor[0];
                                    versionMinor = tempArrayMajor[1];
                                    if ( descArray[3] != "" ) {
                                                tempArrayMinor = descArray[3].split("r");
                                    } else {
                                                tempArrayMinor = descArray[4].split("r");
                                    }
                         versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
             flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
             } else {
                                    flashVer = -1;
                         }
             }
             else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
             else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
             else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
             else {                       
                         flashVer = -1;
             }
             return flashVer;
 } 
 
 function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) 
 {
             reqVer = parseFloat(reqMajorVer + "." + reqRevision);
             for (i=25;i>0;i--) {       
                         versionStr = JSGetSwfVer(i);              
                         if (versionStr == -1 ) { 
                                    return false;
                         } else if (versionStr != 0) {
                                    versionArray      = versionStr.split(".");
                                    
                                    versionMajor      = versionArray[0];
                                    versionMinor      = versionArray[1];
                                    versionRevision   = versionArray[2];
                                    
                                    versionString     = versionMajor + "." + versionRevision;   
                                    versionNum        = parseFloat(versionString);
                                    if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) {
                                                return true;
                                    } else {
                                                return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false );    
                                    }
                         }
             }          
             return (reqVer ? false : 0.0);
 }
 // -->
</script>
 
<!-- Start of document placement code -->
<script language="JavaScript" type="text/javascript">
 <!-- 
 var width="100%"
 var height="700"
 var align="Middle"
 
 var url= 'DocFiles%2fVioxx+Cost+Submissions%2fAlex+Alvarez%2fAlvarez+Alex+2005-7-31+cost+submission.SWF'
 var name="DLS 2009"
 
 var alternateContent = 'This content requires the Adobe Flash Player. It either has not been installed yet or is prohibited by your browser security settings. Either'
 	+ ' <a href="http://www.macromedia.com/go/getflash/">click here to get Flash</a> or loosen your browser security restrictions';
 if(isIE && isWin) alternateContent += ' and then <a href="javascript:document.location.reload()">Refresh</a> this page'
 alternateContent += '.'
 if(isIE && isWin) {  
     var oeTags = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '
     + 'width="'+width+'" height="'+height+'" align="'+align+'" id="'+name+'" '
     + 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+requiredMajorVersion+','+requiredMinorVersion+','+requiredRevision+',0">'
     + '<param name="movie" value="'+url+'" /><param name="quality" value="best" />'
     + '<param name="allowScriptAccess" value="sameDomain" />'
     + '<param name="FlashVars" value="extName='+name+'" />'
     + alternateContent
     + '<\/object>';
     document.write(oeTags);   
   } else if(DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision)) {
     var oeTags = '<embed src="'+url+'" quality="best" '
     + 'width="'+width+'" height="'+height+'" align="'+align+'" name="'+name+'" '
     + 'play="true" '
     + 'loop="false" '
     + 'quality="best" '
     + 'allowScriptAccess="sameDomain" '
     + 'type="application/x-shockwave-flash" '
     + 'pluginspage="http://www.macromedia.com/go/getflashplayer" '
     + 'FlashVars="extName='+name+'">'
     + '<\/embed>'
     document.write(oeTags);   
   } else document.write(alternateContent);  
  -->
 </script>
 <noscript>
This content requires the Adobe Flash Player. It either has not been installed yet or is prohibited by your browser security settings. Either
<a href="http://www.macromedia.com/go/getflash/">click here to get Flash</a> or loosen your browser security restrictions.
 </noscript>
 
<!-- End of document placement code -->
 
<!-- End of document code -->
</div>
        </td>
        <td>
            &nbsp;</td>
 
    </tr>
</table>                
                        
                        
 
        
<script language="javascript" type="text/javascript">
<!--
    alert('DataFilePath is :M:\\web\\VIOXXCOST\\DocumentFile\\DocFiles\\Vioxx Cost Submissions\\Alex Alvarez\\
 
FF_SWF_DocFileName is :Alvarez Alex 2005-7-31 cost submission.SWF');
// -->
</script>
<script language="javascript" type="text/javascript">
<!--
	Fev_FocusOnFirstFocusableFormElement();
// -->
</script></form>
    </body>
</html>
<script language="JavaScript" type="text/javascript">clearRTL()</script>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of abel
abel
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bcombe

ASKER

Is it the url on line 120 that you create through server side code and that cannot be found?
Yes.

What happens if you type it in directly?
It will pull up the swf if I artificially add the filename to the end of the same path (without the URL encoding).

Have you tried without the url encoding?
I thought I did - I'll do it again - back in 10min.
Avatar of bcombe

ASKER

Ok - the URL encoding was the evil.
Avatar of bcombe

ASKER

Thanks Abel. The URL encoding was not necessary here.
Glad it works now! Tx for the follow up & pts ;-)