I am having trouble with uploading an Image to my server files.
I am building an online store where, when i add a product, a can select an image for it to.
I have checked my php.ini file to allow uploads, as well as sufficient size of file allowed.
I have set the permissions to the folder where the images are supposed to go to “full control” for “Everyone”
(just to avoid any problems there)
Now, when i open my add product page there is a “Upload Image” button next to a text field,
that opens a separate window containing the upload page code.
The text field is to link the image on my database.
So I click on the “Upload Image” button and the following happens:
Small separate window appears with 2 buttons, Browse and Upload.
I click on browse, and select my image.
The image name now displays next to the browse button.
When I click Upload, it closes the page, the image name displays in the text field next to the “Upload Image”
button in the product adding list for database reference.
I click on add product, and the product , including the image name displays on the database.
But the image did not upload to the specified server folder.
Here is my code…
<body>
<?php if ((isset($_POST["send"])) && ($_POST["send"] == "form1")) {
$file_Name = $_FILES['userfile']['name'];
move_uploaded_file($_FILES['userfile']['tmp_name'], "../graphics/products/".$file_Name);
?>
<script>
opener.document.form1.strImage.value="<?php echo $file_Name; ?>";
self.close();
</script>
<?php
}
else
{?>
<form action="imageupload.php" method="post" enctype="multipart/form-data" id="form1" />
<p>
<input name="userfile" type="file">
</p>
<p>
<input type="submit" name="button" id="button" value="Upload Image" />
</p>
<input type="hidden" name="send" value="form1" />
</form>
<?php }?>
</body>