|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
how do I add and retrieve pictures?
I want to add and retrieve pictures dynamically. I thought that the article about BLOBBING might have been my solution, but I either didn't udnerstand it well enough or it just wasn't what I'm looking for. I thought an easy way to use pictures would be to have a user adda picture to the site with a form for browsing for the file and then giving the file a variable name equal to the filename. Then it would save the file in a picture directory, and add the name of the file to a database with auto incrementing numbers. Then when I wanted to pull a file up, I could use a qeury that calls for a file with a filename = $name. Is this even possible? Maybe I'm not thinking it though. At any rate, I want to have the user upload a file, and then have that file displayed dynamically. thank you.
|
|
#2
|
|||
|
|||
|
any help?
i still cant do it.... any ideas? thanks.
|
|
#3
|
|||
|
|||
|
thecharking,
Are you storing the actual file in the database, or just the path to the file? If you're storing the path, what you need to do when retriving the file is make sur you're putting the value of your image variable (once retrieved) within <img> tags... Otherwise, you will not be able to see the image. HTH!
__________________
____________________________________________ Developer Shed Weekly Writer | DevArticles Forum Moderator Build Your Own KlipFolio Klip With PHP FrankManno.com - Under Construction Design Interactive Group - Under Construction |
|
#4
|
|||
|
|||
|
thanks... but...
Sorry I guess I didn't explain myself well enough. I am not sure of how to get the files in the first place. I am thinking using a form to gather the pictures to be placed in a folder would be best. Thank you.
|
|
#5
|
|||
|
|||
|
Yeah,
It would be best to have a form whereby the user can choose which image to upload... There's an article that deals exactly with that... I understand you read a blobbing article and it didn't help... Out of curiosity what problems were you having? I read that article, and actually based an application off of that... I found it helped very much... What version of PHP are you running on your server? Did you receive any error messages when you attempted to create your script? |
|
#6
|
|||
|
|||
|
info
yes I read the blobbing article, and implemented it into my site, which uses includes and uses the url index.php?page=$variable for everything pretty much. When I load ?page=getfiles, I get the getfiles page. I enter a short little word or something for description, and then I get my file. I click upload and get this message:
You must enter both a description and file I tried just leaving that error checking out, because I am not too worried about getting a description at the moment. I then tried upl,oading and got this message: Warning: fopen("", "r") - Invalid argument in c:\phpdev5\www\prp\grabfile.php on line 25 Warning: fread(): supplied argument is not a valid File-Handle resource in c:\phpdev5\www\prp\grabfile.php on line 26 File Uploaded The details of the uploaded file are shown below: File name: File type: File size: Uploaded to: Add Another File There are two database entries that I don't know where they came from, nor do they have anything in them but the blob id and blob data. These are not being sent by my pages now... so don't know how they got there. But they seem to be empty all the same. I am running PHP version 4.2.2 on my windows XP PRO machine. I have everything turned on coprrectly and such, I have checked these settings time and again while looking at different forum posts. another wuestion I have: won't blobbing simply put the picture into a database, and that eat up a lot of room and make for a large database? is there a way to just save the file to a folder, and then have it retrieved using php? I think that would be best... but maybe that is blobbing maybe I missed the point. I hope I didn't screw something up bad here. thanks so much, your help is much appreciated. |
|
#7
|
|||
|
|||
|
just got another version
i just downloaded 4.2.3 of php... its the phpdev installer, and then i got the upgrade from 4.2.3 to 4.3.0, but it didn't work although it said it did. at any rate, i hope this isn't the cause of my problem. please let me know what to do if it isn't, or, if it is, for that matter. thanks.
__________________
hey it's the CHARKING |
|
#8
|
|||
|
|||
|
what would work best
okay well i've been restless about the pictures thing, and really wanted to know what my site would look like with them implemented. so I set up a pretty good way of retireving pictures that I had placed in a folder in my site. It will work like this, assuming I am able to jsut allow people to add pictures to a folder from the site... I am still not sure of how, or if it is possible.
I am going to just use the picture name and turn it into a database row. That way it will jsut get the pic name by matching them. It works super well. Maybe it would be best to have the pictures sent to an admin email first any way, and then the admin can load the picture in... no that's too much work. sorry jsut thinking out loud... well silently but in type... anyway If anyone can help with this, it's what I think would work best. the user submits the picture. it is them placed in a temp picture folder, and then a php page (viewed by the admin) can just pull each pic up, maybe with a chechbox or something, you know, so when it is submited, it can input the data into the database according to variables already passed when the user put it into the temp folder. i think (if this is possible) I could do most of this if I simply knew how to get the pictures in teh first place. it's something that has been bothering me for quite a while now, as most of my site is made up of this picture funtion. Thanks for reading, I know, this must be tiresome. Lemme know also if maybe I am going about this in the wrng manner, if this is mroe difficult than it should be, but this seems good to me... thanks! |
|
#9
|
|||
|
|||
|
this is probably dead, but this is how i did it.. and maybe someone one day will be looking for the solution and they find it.
![]() form to use: <FORM NAME="imgupld" ENCTYPE="multipart/form-data" ACTION="getimg.php?sid=$sid" METHOD=post> <INPUT TYPE="file" NAME="attach" SIZE=40> <INPUT TYPE="Submit"> </FORM> now the getimg.php file: $ufolder = "/httpd/html/filesuploaded/"; if ($_FILES['attach']['name'] != "") { //make sure file name is lower case. $_FILES['attach']['name'] = strtolower($_FILES['attach']['name']); //get rid of spaces $_FILES['attach']['name'] = str_replace(' ', '_', $_FILES['attach']['name']); //get rid of '$' $_FILES['attach']['name'] = str_replace('$', '_', $_FILES['attach']['name']); if ($_FILES['attach'] != "") { copy($_FILES['attach']['tmp_name'], "$ufolder".$_FILES['attach']['name']) or die("Couldn't copy the file!"); } else { die("No input file specified"); } or something along those lines... it probably wont work as is.. but the basis is there. ![]() besides, im looking for a solution for something else :S |
|
#10
|
|||
|
|||
|
thanks
thank you for the help, although yah the thread was dead, I figured it all out a while back sorry. And I too am now having a new problem.
![]() |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > how do I add and retrieve pictures? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|