Hello,
I am now up to chapter 10 on “Build your own website using PHP & Mysql” and have hit a brick wall, could anybody assist.
I have a simple file upload script which takes the input field type “file” and uses the $_FILES array to take the tmp name and copies it to my desired directory, but I get the following error.
failed to open stream: HTTP wrapper does not support writeable connections in C:\wamp\www\db-sites\ch10\fileUpload.php on line 9
The script is extremely basic:
<?php
$fileTempName = $_FILES['upload']['tmp_name'];
$fileOrigName = $_FILES['upload']['name'];
$fileSize = $_FILES['upload']['size'];
$fileType = $_FILES['upload']['type'];
$targetFileName = "http://localhost/db-sites/ch10/" . $fileOrigName;
if (!copy($fileTempName, $targetFileName))
{
echo "failed to copy file.";
}
?>
<html>
<head>
<title>file has been uploaded</title>
</head>
<body>
<h1>file has been uploaded</h1>
<ul>
<li><?php echo $fileTempName; ?></li>
<li><?php echo $fileOrigName; ?></li>
<li><?php echo $fileSize; ?></li>
<li><?php echo $fileType; ?></li>
<li><?php echo $targetFileName; ?></li>
</ul>
</body>
</html>
Which makes me think it is a config / directory thing with Wamp?
If it is any help, no matter what file I upload I can never get windows to find the $fileTempName.
Perhaps someone has had experience with WAMP before?
Many thanks