dustydoc Posted June 15, 2008 Share Posted June 15, 2008 Hey, I'm planning on attempting to upload images alongside my text reviews and understand storing inmages in databases is a no-no, so i was looking to use php/html to upload images from my desktop to a image folder and place a link in the database to extract the images with the text at the same time (eventually in Flash). Does this sound like the correct idea?? This is my first website!LOL! 1) How do i upload an image into a designated folder using html/php form?? 2) Any tips on how to manage the images to easily reference them from a database with said text? Indices? By name? 3) How might i thumbnail the ideas, as to see images uploaded alongside my text before pushing all data types through a flash front end?? best Nich Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted June 15, 2008 Share Posted June 15, 2008 1.) Start with the manual's description of file uploads. If you're still not sure, you'll find plenty of tutorials if you google. 2.) Store the file name, caption (i assume that's what you meant by text) and a unqiue ID 3.) You'll find plenty of tutorials for thumbnail creating if you google. Quote Link to comment Share on other sites More sharing options...
dustydoc Posted June 15, 2008 Author Share Posted June 15, 2008 Thanks man. Quote Link to comment Share on other sites More sharing options...
dustydoc Posted June 15, 2008 Author Share Posted June 15, 2008 So once i have completed the html form: 1) How would i then place the image in an external folder using php?? 2) Is it perhaps best to place all image extensions in a new database table and link text_title to image_title from my text table when extracting for display?? Or is this unneccessary and just add an extra row to my text table?? Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted June 15, 2008 Share Posted June 15, 2008 1.) Did you read the link i provided? What do you mean by an 'external' folder? 2.) Well, that would depend on how your system is to work. If there is one piece of text per image (i.e. a caption) per image then you just want one table. If there are multiple pieces of text for each image (i.e. a commenting system), then you'll want a separate table for your images. Quote Link to comment Share on other sites More sharing options...
dustydoc Posted June 15, 2008 Author Share Posted June 15, 2008 Thanks for your help so far Ben much appreciated. Well i think i'm a little confused, i guess i always thought you placed images in an images specific folder and then just use the <a href=""> to link and display the image, i take it i'm thinking about this wrongly?? Brief I have an existing database table i can add and delete several types of text to display, from film director to film review, author, post date etc, but obviously i want to place a picture of the film cover to match with my review. Ideally i'd like to add an image as i add the text and be able to view the results as they might appear after a person has searched my webpage. I need this function as i intend to eventually allow more contributors to access and add reviews etc by themselves, as some people are in japan, some in finland, some in UK. But i'm unclear as where to even start with images. Hopefully someone on here can help. best nich Quote Link to comment Share on other sites More sharing options...
dustydoc Posted June 16, 2008 Author Share Posted June 16, 2008 When uploading an image, how do you use php to post the image into an image folder on the server instead of placing it in a database?? Quote Link to comment Share on other sites More sharing options...
bkiatenxi Posted June 16, 2008 Share Posted June 16, 2008 hmmmm, did you read the manual on the very first reply? all you need is there... Quote Link to comment Share on other sites More sharing options...
mark110384 Posted June 16, 2008 Share Posted June 16, 2008 To display the image <img src = '$imagepath' alt = '$alt' height = 60 width = 60 border = 0/> just put the file path in the database and refer to it via $imagepath. Quote Link to comment Share on other sites More sharing options...
dustydoc Posted June 16, 2008 Author Share Posted June 16, 2008 i have found this php script to place an image into a folder on the server, but only get an error message of file not uploaded?? <? $folder = "/root/phpforflash/chapter9/DocStock/Images"; if (is_uploaded_file($HTTP_POST_FILES['filename']['tmp_name'])) { if (move_uploaded_file($HTTP_POST_FILES['filename']['tmp_name'], $folder.$HTTP_POST_FILES['filename']['name'])) { echo "File uploaded"; } else { echo "File not moved to destination folder. Check permissions"; }} else { echo "File is not uploaded."; } ?> Quote Link to comment Share on other sites More sharing options...
dustydoc Posted June 16, 2008 Author Share Posted June 16, 2008 $folder = "/root/phpforflash/chapter9/DocStock/Images"; Does this extension exist if i'm using apache?? Quote Link to comment Share on other sites More sharing options...
Jabop Posted June 16, 2008 Share Posted June 16, 2008 $folder = "/root/phpforflash/chapter9/DocStock/Images"; Does this extension exist if i'm using apache?? I don't understand your question. Change that directory to your own directory. Quote Link to comment Share on other sites More sharing options...
dustydoc Posted June 16, 2008 Author Share Posted June 16, 2008 <? $folder = "http://localhost/root/phpforflash/chapter9/DocStock/Images/"; if (is_uploaded_file($HTTP_POST_FILES['filename']['tmp_name'])) { if (move_uploaded_file($HTTP_POST_FILES['filename']['tmp_name'], $folder.$HTTP_POST_FILES['filename']['name'])) { echo "File uploaded"; } else { echo "File not moved to destination folder. Check permissions"; }} else { echo "File is not uploaded."; } ?> From this i get an error about the HTTP not having writeable status, is that because of apache as the temporary file is created on my harddrive? Warning messages below: Warning: move_uploaded_file(http://localhost/root/phpforflash/chapter9/DocStock/Images/P1000317.JPG) [function.move-uploaded-file]: failed to open stream: HTTP wrapper does not support writeable connections. in C:\Program Files\FlashInternet\xampp\htdocs\root\phpforflash\chapter9\DocStock\upload_image.php on line 4 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\Program Files\FlashInternet\xampp\tmp\php62.tmp' to 'http://localhost/root/phpforflash/chapter9/DocStock/Images/P1000317.JPG' in C:\Program Files\FlashInternet\xampp\htdocs\root\phpforflash\chapter9\DocStock\upload_image.php on line 4 File not moved to destination folder. Check permissions Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.