BR
asked on
How can I upload multiple pictures to my web page with php?
How can I upload multiple pictures to my web page with php?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
As far as I know, that code is secure enough. It is basic because, for instance, I sometime prefer to change the picture name, or I want to create thumbnails and so on. Since you are uploading images storing them on the server I don't think there are security risk.
ASKER
Thank yo very much Marco Gasi
ASKER
Thank you
You're welcome!
ASKER
Dear Marco,
Something wrong with the code?
On this bold line, php gives error
$valid_formats = array(
'jpg',
'png',
'gif'
)
if (isset($_FILES['pictures'] ['name']) && !empty($_FILES['pictures'] ['name'])) {
Something wrong with the code?
On this bold line, php gives error
$valid_formats = array(
'jpg',
'png',
'gif'
)
if (isset($_FILES['pictures']
Did you change the name of your input element?
ASKER
I changed nothing, I just copied and pasted the code
What is the error message?
And can you show me your whole script?
ASKER
please see attached file, on the line 19 th, there is a problem.
it didn't show the page at all.
upload.php
it didn't show the page at all.
upload.php
ASKER
I found it :)
its a semicolon
its a semicolon
I can't find the semicolon but I'm happy you have found the problem :)
ASKER
after this,
$valid_formats = array(
'jpg',
'png',
'gif'
)
a semicolon was needed
$valid_formats = array(
'jpg',
'png',
'gif'
)
a semicolon was needed
Wooops, I'm sorry!
Hi Braveheartli. I saw you posted another question about the same argument: did something go wrong with my solution?
ASKER
Sorry Marco,
I couldn't make it work.
firs it was the button missing? Then I put a submit button, but it didn't upload anyway. I'm sorry. Thank you anyway.
you taught me a lot. ( I learn a lot from you )
I couldn't make it work.
firs it was the button missing? Then I put a submit button, but it didn't upload anyway. I'm sorry. Thank you anyway.
you taught me a lot. ( I learn a lot from you )
Yes, I didn't add the button because I thought the code would have been inserted in an existing form so I wanted only to show you the input element.
Anyway, that's strange because that ia piece of code I extracted by a my working script using in one of my sites...
I saw you prefer to upload each image separately, so I leave that to Julian, but the only thing I can think to is that maybe you don't have created the directory 'uoload' in your server (path is relative), so the upload fails because php doesn't create automatically a directory if this doesn't exist.
Anyway, that's strange because that ia piece of code I extracted by a my working script using in one of my sites...
I saw you prefer to upload each image separately, so I leave that to Julian, but the only thing I can think to is that maybe you don't have created the directory 'uoload' in your server (path is relative), so the upload fails because php doesn't create automatically a directory if this doesn't exist.
ASKER
Thank you very much.
What is the most secure way to do this?
Is this code is enough to secure the server while uploading files?
If this code is basic,
Do you have the more comlex and secure code for image upload?