php image upload and mysql help

Joined
12 Feb 2006
Posts
17,220
Location
Surrey
having troulbe with the file upload part of my website. im trying to get it so that a person has to select a category and then upload up to 6 images for that category. then have the images stored in upload folder, and have the image name and category stored in database so that i can have a page load image that are for that category. now i got the category working, along with suggestions of new categorys getting stored. The trouble i was having is that i couldn't get the multiple image to work or to have it so atleast one image needs to be uploaded so i have decided to start again with my code.

Im asking of ways in which i can it so that atleast the first image has to be uploaded into the upload folder, the rest being optional and then it stores the name of the image(s) and what category they are for.

any advice on this or a better way to do it? was thinking instead have it like directory and that the person would navigate to a page and then the image just uploads to the folder for that page, and not store any category in mysql as it woudlnt be needed. Reason i haven't tried this already is because i want it to people can suggest new category while uploading an image. hmm thinking about it now i think i will try this as i can just do a form that people fill out without uploading images so that the user suggest the new category first.
 
Last edited:

Sic

Sic

Soldato
Joined
9 Nov 2004
Posts
15,365
Location
SO16
the way i do it is the user uploads their photo and can suggest a category at the same time as choosing a file. they can also choose one of the categories that already exists. each category matches a directory

it goes something like this:

choose image/category->click upload->check image format, cleanse name and whatnot->check db for new category (if it doesn't, create it)->check directory exists (if it doesn't, create it)->move file->done!

if you want to upload multiple images, use the html form field array-a-majigger and loop through $_FILES.

simple :)

if you need a hand, drop me a mail and i'll send you my source to peruse
 
Soldato
OP
Joined
12 Feb 2006
Posts
17,220
Location
Surrey
while i've got this thread, can someone please tell me how i got about styling the <input type=file> i've googled and it appears that its not easy. my main need is to make it so that the browse button is under the white space.

tahnks
 
Last edited:

Sic

Sic

Soldato
Joined
9 Nov 2004
Posts
15,365
Location
SO16
as far as i'm aware, it can't be done. one of the most annoying things about web design. if anyone can say otherwise, i'd be very interested to hear!
 
Soldato
OP
Joined
12 Feb 2006
Posts
17,220
Location
Surrey
ok new problemo, as the script was way too advanced that sic give me i decided to go with what i knew and make a simple image uploader that is located in each category and will upload the images to that category folder. I have php read whats in the folder and display them as clickable thumbnails but dont know how to get it so if there is too many images add pages.

I have looked at pagination but don't understnad how it works one bit if someone would be so kind and explain?

Also when people suggest a new category the first bit if selecting where the new category is located from a dropdown list. Is there a way i can have this list update itself so that if a new category is added, the list will automatically add that category.

The form for this has values of newmaincat, newsubcat1, newsubcat2. i would want the form to display the root folder, then newmaincat, with newsubcat1 in that, then with newsubcat2 within that.
Can i do this on a seperate file and jsut do an include e.g.

<select>
<?php include ("categorys.php"); ?>
</select>

sure i wrote that terribly but hope someone can understand what i mean
 
Last edited:
Soldato
OP
Joined
12 Feb 2006
Posts
17,220
Location
Surrey
i have made a php script that makes a new folder, and then copies and pastes 7 files into the new folder and creates a link to them.

To build this script i kept testing it out making 5 folders that i no longer need. problem i have is i can't get rid of them when i try deleting them via filezilla ftp and through cpanel file manager and i get a "550 Could not delete Permission denied" message. i tried using unlink and rmdir but either its because im a noob with them 2 functions or that wasn't allowed either but it didn't work. In the end i had to use php script to change the folders permission to 777 which is annoying as its too much work to delete a folder

what permission should i set for these files and folders so that in future i don't have to use a script to delete them?

this is the code i use to make the folder: mkdir("$newfolder", 0777); but its making it 755
 
Last edited:
Back
Top Bottom