I want to browse all folders on my computer without using opendir(), in PHP.
I think I managed to extract the real question out of the comments: What you actually want is to provide an upload of multiple files.
Answer: No this is not possible with PHP, since it is executed by the server, not by the browser. PHP can give you folders on the server, not on the machine of the user. If you want to upload multiple files in a single step, you should use flash, javascript or something similar.
Why wouldn't you want to use the function that's actually provided to do what you want?
In one of the comments, seeming says:
i want the user to select couple of
files and upload rather than having
multiple upload boxes. why are people
downvoting this question?
Well, it is because your question is unclear and it is impossible to answer without the context of multiple file uploads.
The answer is: you can't do that with PHP.
PHP runs serverside, so it can only give you a list of all the folders on the server; not the folders on the client side.
So the solution you need will either be
a Java-Applet (Facebook uses this for multiple file uploads)
or Flash/Flex (Gmail multiple file upload)
The result will be a very ugly combination of glob() and stat(). Is there some reason you can't work with opendir() and friends?
Edit:
If PHP does not have suitable permissions to access everything you want to see, using another function is not going to help.
What (exactly) are you trying to do?
Why don't you use the following?
opendir(DIRECTORY_SEPARATOR);
Related
I need to upload a single specific file (Ex. "C:\test.jpeg") to the web server using HTML5 components "FileAPI" and "XMLHttpRequest". Is it possible?
I have seen all types of examples that include drag and drop options, but I need less than that. I just need to call the JavaScript function, and I will send the path of the file I need to upload to a specific folder on the server.
IMPORTANT: I CAN NOT USE THE INPUT TAG. IT MUST BE DYNAMICALLY
Thanks in advance.
You cannot have arbitrary access to the filesystem from the browser, even with HTML5's Filesystem API. This has been discussed in many other threads on Stackoverflow. Have a look at one of the more recent threads, for example: Some questions about HTML5 FileSystemAPI.
I am building a website where I am uploading images to my ftp folder through PHP script. Now I want to display those images on to my HTML pages. I was thinking about using PHP and getting array of all the images from my ftp folder and then display them using image view.
Please tell me if I am doing this the wrong way and if there is any other better alternatives to it. I was reading php manual for ftp_nlist and ftp_rawlist but did not understand.
Well it may depend on how many images you have in there. Probably the most "correct" way to do it would be to store the filenames in a DB. You could scan the entire folder, but for every single request that's potentially a lot of overhead rather than just grabbing them out of a DB.
Are you manually uploading the images? Give us more details on how that works and we can better serve you. If you're using a script to upload images (I've had lots of projects where that's the case), then you can just have the script insert those filepaths into the DB for you. If not, (you're manually uploading them), or if indeed there are not a large number of files, then scanning the folder wouldn't necessarily be a bad thing. I've used that method on smaller projects myself.
Read up on the php readdir function in the docs (which actually works a lot like mysql_fetch_assoc, ironically)- That will provide you with an excellent way to go without setting up a DB. For an approach where an upload script handles it, I recommend a DB. Without more info, it's hard to say.
Good luck!
I'm looking for free php and jquery(would be nice) upload script which I could
include in my webpage.
It must be able to upload multiple files, and make a
link for them.. as in mysite.com/randomstuff with a list of files
or if I upload one file, then it will redirect to hotlink and then people
wont have to click anything.
It must have easy way to upload files without logging in
so that when I upload I could just give the link to my clients
or friends so that they could download some support files, fixes, etc.
Thanks!
Have a look at this:
http://www.uploadify.com/
It is easy to use jquery and php uploading method. you can upload multiple files at a time.
Hope this helps.
For simple uploads (inc multiple files/good interface), this is what you need: http://www.uploadify.com/
However, it won't do all the url stuff for you. There may be another decent plugin for that. Or you could try some, you know, coding.
You can use a file upload script like the ones mentioned before, but I found that http://www.plupload.com/ is very nice to use.
Anyway, you will still need to code some php to make it work the way you want.
I have a dynamic web site (php/mySQL/Ajax on a Linux server), I need to take automatically a photo (snapshot) of each web page periodically (If I can find the way to do the snapshot... I can use cron) and save this image to the database (I also know how to do this...my only problem is the photo!).
I can't do it manually, so I need an script which take the snapshop for me, without displaying the web page, i.e directly from the .php files.
How is it possible?
Thanks!
http://browsershots.org/ may work for you, they have an api
You can use the GD functions imagegrabscreen() or imagegrabwindow() to take a screenshot.
Note that they're only available on Windows at the moment.
Looks like this might answer your question, I have seen it done with php and flash but wasn't privy to the inner workings, if the link doesnt help then you could research that route.
I need a php code and sql code that will let someone upload an image to a database. The only thing I can find is very glictchy and not accepted by some browsers. Any ideas?
NEVER store images in the database. NEVER EVER EVER EVER. There are tons of other questions posted here about it that you may want to ready up on.
Always store directly on filesystem, and store the image URL of the file in the database.
If I understood correctly, you want to upload image files (or any files) via browser to the server and save them in the database. If that is the case, read this:
http://www.php-mysql-tutorial.com/wikis/mysql-tutorials/uploading-files-to-mysql-database.aspx
There are likely lots of available tutorials online to show you how to do this (you might take a look at this one: http://www.codewalkers.com/c/a/Database-Articles/Storing-Images-in-Database/).
I think that this is not the most efficient way to handle images, however. You might consider writing them to a folder and simply keep the name of the file and its location in the database. This stackoverflow question might help: How to store file name in database, with other info while uploading image to server using PHP?