# PHP Help! (SOLVED)

**URL:** <https://forum.kirupa.com/t/php-help-solved/637676>\
**Category:** web dev\
**Created:** [December 30, 2017, 6:26am UTC](https://forum.kirupa.com/t/php-help-solved/637676 "2017-12-30T06:26:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bbpanzu](https://avatars.discourse-cdn.com/v4/letter/b/f19dbf/32.png) [@bbpanzu](https://forum.kirupa.com/u/bbpanzu)\
**Post date:** [December 30, 2017, 6:26am UTC](https://forum.kirupa.com/t/php-help-solved/637676/1 "2017-12-30T06:26:00Z")

</div>

This is the code i use:

\<?php $target\_dir = "uploads/"; $target\_file = $target\_dir . basename($\_FILES["fileToUpload"]["name"]); $uploadOk = 1; $imageFileType = strtolower(pathinfo($target\_file,PATHINFO\_EXTENSION)); // Check if image file is a actual image or fake image if(isset($\_POST["submit"])) { $check = getimagesize($\_FILES["fileToUpload"]["tmp\_name"]); if($check !== false) { echo "File is an image - " . $check["mime"] . "."; $uploadOk = 1; } else { echo "It's fan **ART**. (Not a picture format)"; $uploadOk = 0; } } // Check if file already exists if (file\_exists($target\_file)) { echo "There can only be one of those. (Already exists)"; $uploadOk = 0; } // Check file size if ($\_FILES["fileToUpload"]["size"] \> 500000) { echo "YO! Your pic is great, but it's too heavy for us to carry. (File size too large)"; $uploadOk = 0; } // Allow certain file formats if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif" ) { echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed."; $uploadOk = 0; } // Check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { echo "Umm....this is akward.....it kinda sorta maybe wansn't uploaded"; // if everything is ok, try to upload file } else { if (move\_uploaded\_file($\_FILES["fileToUpload"]["tmp\_name"], $target\_file)) { echo "You picture, ". basename( $\_FILES["fileToUpload"]["name"]). " has been uploaded."; } else { echo "Umm....this is akward.....we kinda can't upload it"; } } I keep getting this error File is an image - image/png. Warning: move\_uploaded\_file(uploads/happy monika (get it bc honica rhymes with monika.....i celeberate christmas.....).png): failed to open stream: No such file or directory in /storage/ssd3/509/3965509/public\_html/upload.php on line 38 Warning: move\_uploaded\_file(): Unable to move '/storage/ssd3/509/3965509/tmp/phpbsZQLi' to 'uploads/happy monika (get it bc honica rhymes with monika.....i celeberate christmas.....).png' in /storage/ssd3/509/3965509/public\_html/upload.php on line 38 Umm....this is akward.....we kinda can't upload it Can some one tell me what's wrong?
