1st question: could this be a permission limited on the read and write of images? i'm using mac osx
2nd question:Is that why i keep getting echo"please enter all infor" from the if statement because the images is not correctly upload?
3th question: on define(''GW_UPLOADPATH','/Library/WebServer/Documents/gw/images/'); do i have to type in the location of where the images folder is or the DW will know exactly where to save it since the folder is in the same as the web folder
thank you for your time
Expand|Select|Wrap|Line Numbers
- <?php
- define('GW_UPLOADPATH','/Library/WebServer/Documents/gw/images/');
- if(isset($_POST['submit'])){
- $name=$_POST['name'];
- $score=$_POST['score'];
- $screenshot=$_FILES['screenshot']['name'];
- echo "filename is $screenshot";
- if(!empty($name)&& !empty($score)){
- $target=GW_UPLOADPATH.$screenshot;
- echo "Moving file to $target";
- if(move_uploaded_file($_FILES['screenshot']['tmp_name'], $target)){
- $dbc=mysqli_connect('localhost','***','****','guitar');
- $query="insert into guitarwars values(0, now(),'$name','$score','$screenshot')";
- mysqli_query($dbc, $query);
- echo'<p>Thankys for adding your new high score!</p>';
- echo'<p><strong>Name:</strong>'.$name.'<br/>';
- echo'<strong>Score:</strong>'.$score.'<br/>';
- echo'<img src="'.GW_UPLOADPATH. $screenshot.'" alt="Score image"/></p>';
- echo'<p><a href="index.php"<< Back to high scores</a></p>';
- $name="";
- $score="";
- mysqli_close($dbc);
- }
- else{
- echo'<p class="error">Please enter all the information.</p>';
- }
- }
- }
- ?>
- <form enctype="multipart/form-data" method="post" action="<?php echo $_SERVER['php_self'];?>">
- <input type="hidden" name="MAX_FILE_SIZE" value="32768" />
- <label for="name:">Name:</label>
- <input type="text" id="name" name="name" value="<?php if(!empty($name)) echo $name;?>"/>
- <br/>
- <label for="score">Score:</label>
- <input type="text" id="score" name="score" value="<?php if(!empty($score)) echo $score;?>"/>
- <br/>
- <label for="screenshot">Screen shot:</label>
- <input type="file" id="screenshot" name="screenshot"/>
- <hr/>
- <input type="submit" value="Add" name="submit"/>
- </form>