No problem.
No problem.
Its a great script... would it be possible to upload multiple images using one submit button only? I tried but it did not work...can you help me... show me how to do it ... thanks so much
Yes, in the HTML you will need to specify the image variable as an array:
Notice the brackets [] on the image name (image[])? That allows you to upload multiple images via HTML. In PHP you will need to iterate through the image[] array.HTML Code:<form enctype="multipart/form-data" action="insert.php" method="post" name="changer"> <input name="MAX_FILE_SIZE" value="102400" type="hidden"> <input name="image[]" accept="image/jpeg" type="file"> <input name="image[]" accept="image/jpeg" type="file"> <input name="image[]" accept="image/jpeg" type="file"> <input name="image[]" accept="image/jpeg" type="file"> <input value="Submit" type="submit">
I can't get this script to work.
Everytime I try to upload an image, I get the following error: No image selected/uploaded.
Is there a problem with the script?
Edit: Stupid me. I had set the maximum filesize way too low!
So now it's working!
Thanks for the tutorial!![]()
it is a good tutorial and code for php learner
hi
retrieve the contents from database, and save it in a image formated file, call it from html
Hi I have followed all the steps and I understand the concept behind uploading and displaying an image(according to Jaan), however the image still does not display for me.
I believe the problem is with the rights of the file or something. The reason why I think so is because i have tried uploading an image to the "uploads" folder with ftp and i can easily display it however if i upload the same exact image with the upload form and then i try to view it I get the following message "403 Forbidden".
If it makes any difference I am using a hosted site.
Any idea why when i upload an image with the upload form it becomes forbidden in the folder?
Thank you Very much in advance
A 403 means you can't access your PHP script. You probably have bad permissions, as you stated. chmod 755 it and try again.
So what permission rights must a folder technically have?
Initially i had the following permissions:
(and if you chmod 755 it this is how permissions will end up)
Me: Read and Write
Staff: Read only
Everyone: Read only
then I changed them to
Me: Read and Write
Staff: Read and Write
Everyone: Read and Write
and still get the forbidden message.
Btw I have the following setup:
mywebsite.com contains a folder "uploads"
mywebsite.com contains all of my php pages
I am trying to store just the path in the database and the actual image files
in the upload folder.
I host my website, so in order to make sure that my folder(uploads) had read and write access rights(which i assume are correct) i have created it on my computer and then sent it with ftp to my host. So I assume the folder still has the correct permission rights set up.
It is weird that it works fine if i ftp and image (i am then able to view it). But if i use the uploads form it does get uploaded but i cant view it and get that "forbidden" message.
Thank you so much for your help!
Hi Jordan! thanks for help.
So I discovered that after I upload my image with the file upload form, the actual image's permission settings change. They change to no read rights. Therefore somewhere in my upload form i have to chmod 755 the actual file but I am not sure how to do so.
Could you please help me out? and here is the code I have to actually upload the image:
Code:if(isset($_POST['submitted']))
{
$uploadDir = 'uploads/';
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];
$filePath = $uploadDir . $fileName;
$result = move_uploaded_file($tmpName, $filePath);
if (!$result)
{
echo "Error uploading file";
}
if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
$filePath = addslashes($filePath);
}
}
Last edited by Jaan; 05-31-2009 at 06:29 PM. Reason: Please use code tags when you are posting your codes!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks
Algorithms and Data Structures
Java tutorials
Algorithms Forum