FlashBuilder: How to get file location from FileReference object? - apache-flex

How can I browse to a file and send file location to the backend using FileReference object?
I am using flex 3.6.

Due to security purposes; you cannot get the file location using FileReference in a browser based app; you can only get the file name.

Related

Insert Image from Symfony path with PHPExcel

I'm trying to insert images in my Excel using the PHPExcel_Worksheet_Drawing of PHPExcel (in this Symfony Bundle) but I get this message all the time:
File http://benefest.local/uploads/persons/image/58af244d3f58c_16143190_10210682923503464_8658615512523719175_n.jpg not found!
Here is my code:
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setPath($path);
$objDrawing->setWidth(30);
$objDrawing->setCoordinates('A1');
$objDrawing->setWorksheet($phpExcelObject->getActiveSheet());
My images are uploaded by VichUploaderBundle, and I'm generating the absolute path through a function. which returns me http://benefest.local/uploads/persons/image/58af244d3f58c_16143190_10210682923503464_8658615512523719175_n.jpg
In a browser, this image is displayed!
Any clue?
Answer is based on my comments to this question.
There is a difference between URI and file path:
URI - used in browser, or being more general in HTTP protocol to get access to some resource via web-server
File path - a link to some file within filesystem on your server/computer/etc.
Your function returns a URI string (http://benefest.local/uploads/persons/image/58af244d3f58c_16143190_10210682923503464_8658615512523719175_n.jpg), which can be used to access the image via a web server.
But PHPExcel_Worksheet_Drawing as well as other libraries use PHP's filesystem functions to get access to some file locally. So you need to get a local file path, instead of URI (in you case it is ./uploads/persons/image/58af244d3f58c_16143190_10210682923503464_8658615512523719175_n.jpg).

set default location to download to using the file class in flex

I have a exe file I want to download, using a url.
I'm using the File class and calling the download(url) function to download the file.
This lets me choose a place to download the file, but the default is either the path of the application directory or the last place the user choose to save a file. This sometimes causes problems because the user will try to save it to their application directory, but we don't allow them to have write access to the folder.
I want to be able to set the default to somewhere like the downloads folder. Is there a work around to achieve this?
update: Actually i found the answer. you just place the path in the file creation. var file:File = new File("path");
I'm guessing you meant to ask about the FileReference class because the File class doesn't have a download function.
From the asdoc on FileReference:
The FileReference and FileReferenceList classes do not let you set the default file location for the dialog box that the browse() or download() methods generate

How to create a QPicture from a resource in Qt?

I have a resource at :images/pic.gif
Can I make a QPicture from this resource or does it have to be loaded from file?
QPicture is for recording QPainter commands, not for image data.
If you want to load an image, use QPixmap or QImage. You can use their load() methods.
To access an image file bundled as a resource, use ":/" to access the resource: ":/someFile.png". The exact paths and filenames are specified in the qrc files.
I think your question is like after adding images/pic.gif into the resource file whether it has to be accessed from the resource file or the directly the location of images/pic.gif.
Now my answer for the question is, even if you have added the images into resource file and accessing it, it will indirectly access the physical file itself. To illustrate this, after adding the images/pic.gif into the resource file, try removing the images/pic.gif from the location and access within your application. You will not able to get the image. So, even if you add it into the resource file it is similar to access the physical file present in its original location. Check out the Qt Resources page.
But it is a good practice and logical to organize your required files into a resource file so that all the required files are present in the same location.
Using QPicture you can load it into your application through
bool QPicture::load ( const QString & fileName, const char * format = 0 )
you have to use Qicon or Qpixmap to load the images from resource.
QPIcture is used to save the picture.

Setting Default SAVE Locations in flex3 web application

In flex 3 web application how to set default save location for images?
Thanks.
From the FileReference documentation:
The FileReference and FileReferenceList classes do not let you set the default file location for the dialog box that the browse() or download() methods generate. The default location shown in the dialog box is the most recently browsed folder, if that location can be determined, or the desktop. The classes do not allow you to read from or write to the transferred file. They do not allow the SWF file that initiated the upload or download to access the uploaded or downloaded file or the file's location on the user's disk.
If you're using AIR, you have more control using the File class.

ASP.NET: Open File From URL

In ASP.NET, I have an XML file (within my project) that I would like to deserialize. FileStream objects do not allow you to open a file via URL.
What is the easiest way to open the file so that I can deserialize it?
If the file is within your project you just need to get the physical location of the file. You can use Server.MapPath("/yourfile.txt") to get the phyical location and then open it with a filestream.
you can use the XmlDocument.Load(url) method which will load an XML Document from a URL

Resources