Showing results for 
Show  only  | Search instead for 
Did you mean: 

Photo Upload is not working in my site ?

 I have written the code for uploading photo to my site is as follows,


$file_formats = array("jpg", "png", "gif", "bmp","JPG","jpeg" ,"JPEG","PNG");
$filepath = "upload/";
if ($_POST['submit']=="Submit") {

$name = $_FILES['photo']['name']; 
$size = $_FILES['photo']['size'];

if (strlen($name)) {
       $extension = substr($name, strrpos($name, '.')+1);
      if (in_array($extension, $file_formats)) { // check it if it's a valid format or not
                    if ($size < (2048 * 2048)) { 
                               $imagename = md5(uniqid() . time()) . "." . $extension;
                              $tmp = $_FILES['photo']['tmp_name'];
                             $f=$filepath. $imagename;
                                 if (move_uploaded_file($tmp,$f)) {
                                                 echo '<img class="preview" alt="" src="'.$filepath.'/'. $imagename .'" />';
                                                                                              } else {
                                                echo "Could not move the file.";}
                                                                                              } else {
                                               echo "Your image size is bigger than 2MB.";}
                                                                                             } else {
                                               echo "Invalid file format.";}
                                                                                             } else {
                                               echo "Please select image..!";}


Actually,the problem comes when the other users try to upload to my site then they are unable to upload.

So,i have looked few topics in godaddy community and had tried different solution but still its not working.



Hey @Jayanta


Unfortunately I'm not a scripting expert, but I know we have a few members here who are. Maybe something would stand out to one of them if they see this discussion and notice something wrong with your code. 


In the meantime; you mention there's an error, but no description of the actual error message itself? Perhaps if you shared that, this might point to something else outside of the coding that needs to be addressed. 


CG - GoDaddy | Community Moderator
24/7 support available at