Forum Moderators: coopster
I am currently trying to upload an image to my mysql file server. It seems to go through however the file is never actually saved on the server. Attached is my code and hopefully someone can catch my mistake.
<form name="form1" method = "post" enctype = "multipart/form-data">
Photographer name: <input type="text" name="authorname" size="40" /> <br />
Upload File: <input type="file" name="filename" id = "filename" size="40" /> <br />
File Type: <select name = "select">
<option value = "JPEG">JPEG</option>
<option value = "GIF">GIF</option>
<option value = "PNG">PNG</option>
<option value = "other">Other</option>
</select>
<br />
Photo Name: <input type = "text" name = "photoname" /> <br />
Photo Description: <input type = "text" name = "photodescription" />
<br />
<input type="submit" value = "submit" />
<input type="reset" value = "reset"/>
</form>
<?php
include("connect.php") ;
$path = "/images/" ;
$authname = $_POST['authorname'];
$phototype = $_POST['select'];
$photoitself = $_POST['filename'];
$photoname = $_POST['photoname'];
$photodesc = $_POST['photodescription'];
move_uploaded_file($files['filename'] ['tmp_name'],"/public_html/images/" . $_FILES['filename']['name']);
echo "stored in: " . "images/" . $_FILES['filename']['name'];
?>
the addphoto3.php is stored under the public_html folder of my web server, and there is an images folder within the public_html where i want the images to be stored. Any help is appreciated.
all the folders in my public_html have read/write/executable access for all users. I also changed the file path to just images/. i put in an die clause and got this :
Warning: move_uploaded_file(/public_html/images/doggy.jpg): failed to open stream: No such file or directory in /home/welsh/public_html/addphoto3.php on line 55
Warning: move_uploaded_file(): Unable to move '/tmp/phpn64U28' to '/public_html/images/doggy.jpg' in /home/welsh/public_html/addphoto3.php on line 55
Error: 0
for the code:
include("connect.php") ;
$path = "/images/" ;
$authname = $_POST['authorname'];
$phototype = $_POST['select'];
$photoitself = $_POST['filename'];
$photoname = $_POST['photoname'];
$photodesc = $_POST['photodescription'];
if (move_uploaded_file($_FILES['filename']['tmp_name'],"images/" . $_FILES['filename']['name'])) {
echo 'Image uploaded!';
} else {
echo 'Error: '.$_FILES['filename']['error'];
}
dc