This is a discussion on "File upload" within the PHP Forum section. This forum, and the thread "File upload are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
File upload
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
File upload
Hi, im trying to upload an image using php - ive looked at numerous tutorials and think i know how to do it except i think im missing something basic
to my understanding the following code should output the path that the user enters in the upload form
the name of the upload field in the upload form is "upload_file" and im trying to do this to test why everytime i try to write code to upload the file, it fails. I've even tried to use scripts that are already done and have set the upload directory to 777, though I wasn't aware that this would be needed for the above code to do its job |
|
|
|
|||
|
Re: File upload
I understand it now its
$image_file = $_FILES[upload_file][name] |
|
|||
|
Re: File upload
could anyone tell me whats wrong with this - ive set Image folder to 777
The name of the file from the form is bnr.png The size of the image is The type of file uploaded is image/x-png The temporary path is /tmp/phpMBYQBS The target path is www/Image/bnr.png Could not copy |
|
|||
|
Re: File upload
Is the target path really relative to your current directory, or should you have a ../ or something in front of it?
|
|
|||
|
Re: File upload
I didnt think of that, i bet I should have ../ at the front. I sorted it now anyway (by putting the script into the folder I want to upload images to and just using the file name as the second parameter)
Would you know of an alternative to setting the directory to 777, im bit worried that this is unsafe, im only using the upload for me at the minute (not public) but if I want to allow this facility on the actual site then this from what ive read would be unsafe. Also I read somewhere about using explode() to make sure that the file being uploaded is an image and not a malicious file with an image extension - would you recommend I use this? thanks, |
![]() |
| Tags |
| file, upload |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| PHP+SQL+File Upload | joshlindem | PHP Forum | 5 | May 10th, 2008 16:48 |
| file upload | berry05 | Job Opportunities | 0 | Mar 19th, 2008 19:09 |
| renama file name before upload | mcnika | PHP Forum | 1 | Mar 17th, 2008 12:13 |
| File Upload | magiccupcake | PHP Forum | 1 | Jan 22nd, 2007 05:10 |
| simple file upload? | jimmy_d | PHP Forum | 3 | May 19th, 2006 18:27 |