|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
ftp upload file then store filename in mysql
Hi all, I wonder if anyone could give me a hand with this?..
I am building an online catalogue for a shop. There is an admin section where the administrator can add new products. When adding products, a thumbnail and a full size image are uploaded into a directory, and the uploaded files are referenced in mysql. Hope that makes sense? This is the code I have to do this job: PHP Code:
I get the variables from a multipart/form-data form. I know that my host supports php ftp as I have used other scripts on it before. But it doesn't work! I have tried everything I can think of, but it doesn't upload the files or reference them in mySQL(store the filename). Please can anybody help me? I will be eternally grateful! Thanks! |
|
#2
|
|||
|
|||
|
This isn't the way to do it - have a search for file upload or look in the manual. I can't understand what you are sending in your post vars, but I can't see it working like this.
It's more usual to use HTTP for the file upload, rather than ftp, to do this you have enctype = "multipart/form-data" as you have, but for the images you should use an input type="file". This will give you a browse button, allowing the user to select a local file for upload. Maybe you have done this. Then you access this using $_FILES - if your form field is called "userfile", you have $_FILES['userfile']['tmp_name'] and so on. You should perform some checks on the file being uploaded, and use move_uploaded_file() to save it to a permanent location. This is just an outline, you should be able to find more detail in the manual or this forum. |
|
#3
|
|||
|
|||
|
something sort of like this, you'll have to modify it to create your directories and such. this script just uploads up to 10 images changable by modifying numoffile variable.
PHP Code:
__________________
-Sotonin |
|
#4
|
|||
|
|||
|
Why doesn't this work for me???
I've tried to figure out how to upload files before, but it never seems to work. So after looking at your post, I figured I'd give it a go - but still no !!!
It seems to be working - I click upload, it thinks about it, then reloads the page. I even put in an error check with move_uploaded_files, and there were no errors. But the file never appears!!!! Why oh why? |
|
#5
|
|||
|
|||
|
My code will only work with jpg files.... so that may be part of the problem what are you uploading?
|
|
#6
|
|||
|
|||
|
nope
I was actually trying to upload a .png, just as a test. I converted it to .jpg, then .jpeg, but neither worked. Is it possible that the permissions don't allow this? I'm using a professional server ... maybe they don't want to allow uploading. Is there a way to tell if this is the cause?
|
|
#7
|
|||
|
|||
|
you have to chmod whatever directory you are tyring to upload to to 777. well prolly only 775 but try 777 just to be sure. As far as server settings im not sure to be honest.
|
|
#8
|
|||
|
|||
|
Is there a way to set the chmod settings with Dreamweaver, or another windows program? I've yet to find a way ...
|
|
#9
|
|||
|
|||
|
Is there a way to set the chmod settings with Dreamweaver, or another windows program? I've yet to find a way ...
|
|
#10
|
|||
|
|||
|
Is there a way to set the chmod settings with Dreamweaver, or another windows program? I've yet to find a way ...
|
|
#11
|
|||
|
|||
|
nope. just download a free trial of cuteftp or ftp voyager from download.com
|
|
#12
|
|||
|
|||
|
nope. just download a free trial of cuteftp or ftp voyager from download.com
|
![]() |
| Viewing: Dev Shed Forums > System Administration > FTP Help > ftp upload file then store filename in mysql |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|