Is there a possibility to preselect a local path when downloading a file via php script ?
What I mean is, if I download a file, the browser prompts a window to select download location, if there was no permanently path set. Since there are many OS out there with different fileroots which structure I don't know, I wanted to give the user of my webapplication the possibility to save the savepath to a database. And if he starts a export and file is getting downloaded that the path were the file goes is presetted. Is this possible ? Sorry for my english :D
I searched google without results... may im looking wrong ^^
It is not possible because of security issues. You cannot access users' filesystem via browser without their knowledge - A user has to pick a file/directory/path to save something by their own.
Related
hope someone can help me. I made a unity3d game for webplayer. Now i need to store some data e.g. the time how long someone has played the game in a csv file.
Does anyone know how i can test if my php and javascript for writing to this csv file
in my javascript i habe this line
var postDataURL = "myurl/data.php?";
but i don't have a url til now so i need to test this locally and i don't know what to add for the url i always get this error:
Could not resolve host: C; No data record of requested type
thanks
You will need to set up a web server to run locally. At that point you can target your form submission at http:// localhost/data.php and things will work perfectly. Apache is really easy to set up but you might want to look into something like WAMP (Windows Apache MySql PHP.)
http://www.wampserver.com/en/
First of all in order to access your PHP script to either send or retrieve information You need to use the WWW class with your url.
Next is there a reason that you want to write it to a csv file. If your just trying to store information that is pervasive across all session runs you can write data to player prefs.
PlayerPrefs.SetString("KeyName", Value);
Retrieve the data at any time using
PlayerPrefs.GetString("KeyName")
This is good for keeping high scores and such
Finally to directly answer your question my favorite is installing apache because it sets up in minutes with out havnt to know what your doing
http://httpd.apache.org/
after install find your web root and place the file in there. You can access the file using http://localhost/yourPHPfile.php
Make sure you install php on your machine as well.
I know asp/php are serverside etc..however...
I would like to ask a user to select a dir on their computers hard drive, and be able to generate an XML file based on files found in this directory. I would then save xml file to website .
For example directory has 3 files in it.
c:\music\mp3\
bob1.mp3
bob2.mp3
bob3.mps
My background is vbscript/classic asp. But am happy to do this in PHP. I was wondering if JavaScript/Ajax might be my friend ??
Im not sure where to start ??
No web technology is allowed raw access to the user hard drive. You either need a browser plugin (you can write one!) or some executable on the client.
I'm creating a website that generates a text file. I would like for the user to save the file to a specific folder (it's a backup file for a video game).
Is it possible to change the default folder the file is saved to via PHP or HTML? C#, while not my first pick, would also be acceptable.
If I understand correctly, NO you cannot default to a location on the users computer. This is just a security piece that you cannot get around.
Try educating the user before they download. That's the best way.
No file download locations are handle at the browser level
You could probably package the text file in an installer / extractor that loads it to the location you want, but I don't think you want to go that far ^.^
You cannot prompt the user to save the file to a specific place on his/her computer, you can however save some stuff on the users pc by the use of Web Storage, that is a part of the HTML5 spec. You will not be able to control where it will be saved though.
It would not be a smart move to store backups for your game on the users pc, as it would open a endless world of cheating and hacking.
I'm wanting to setup a php script and host it on my server that will let me download files from other locations, but making it look like it's coming from my server. Maybe using curl or htacess. Also I was hoping that there would be a way to get around having my server deal with the bandwidth. Does that make sense? Is this doable?
-- Update
Kind of like a proxy, but without the file downloading to memory and then sending it to the client.
You can do this by simply passing the target url to you script, open the url with file_get_contents(), curl or other file functions and echo the data. ensure to set the Content-Type header to "application/octet-stream" to force the browser to save the file instead of displaying it.
As for the bandwidth: You'll have to deal with it. If your server downloads a file, it will use up the bandwidth. It will even use it up twice because it has to receive AND send the data.
I don't know why you mention htaccess, because that has nothing to do with your problem.
Also I was hoping that there would be a way to get around having my server deal with the bandwidth. Is this doable?
No.
I'd recommend setting up a linking system on your site like http://example.com/download.php?id=12 that would then forward directly to the remote file, that way you'd save on bandwidth and if someone look at the link on your page it would look like it coming from your server. It would still show the other site in the download manager but if your trying to save bandwidth it's a small price to pay.
Thanks for the help... I figured out what I was needing to do, I'm going to use mod_xsendfile. It lets you set an external source for where the file is located, and then lets the user download the file without knowing where the file actually is located.
I have created a website.In that scaling an image option is created.. Now i want to store that scaled image in users desktop..But its saving in code existing folder..
Please help me by sending php script to store that file in desktop
If your website is going to actually live on the web instead of on people's computers locally then you can't directly save it to their computer. You can serve it to them with php as a file download by setting the proper mime-type and content headers (using header()) followed by the file itself, or better yet offer the user a download link so they can choose to download it themselves.
If your website is going to be used locally (a little odd, but it could happen), then you can use fopen(), fwrite() and fclose() in php to work with local files.
I don't think it is possible to do this without asking for user intervention on where to save the processed file. If you think about it, it would be a significant security flaw if a web server could arbitrarily save files to user desktops!
The best you could do is set the content header of the generated file to have a content disposition of attachment and then the browser will prompt the user where to save the file.