Connecting Tech Pros Worldwide Help | Site Map

Image upload problem

Newbie
 
Join Date: Sep 2009
Posts: 4
#1: Oct 1 '09
Hi buddy,

I have small script which upload the images. This script is working perfectly fine in localhost but when I upload that script to my website then it is not uploading the pictures.

I have subdomain in my website names as http://projects.example.com,

In projects folder I have my photo upload script.

Here I add some code from my file.

Expand|Select|Wrap|Line Numbers
  1.       $numfilesuploaded = $_POST['numuploads'];
  2.       $count = 1;
  3.  
  4.           while ($count <= $numfilesuploaded)
  5.           {
  6.                   $conname = "new_file".$count;
  7.  
  8.                    $filetype = $_FILES[$conname]['type'];
  9.  
  10.                    $filename = $_FILES[$conname]['name'];
  11.                                   echo "<br>";
  12.                   if ($filename != '')
  13.                   {
  14.                     if ($filetype == "image/x-png" || $filetype == "image/pjpeg" || $filetype == "image/gif" || $filetype == "image/jpeg")
  15.                     {
  16.                         $maxfilesize = $_POST['maxsize'];
  17.                         $filesize = $_FILES[$conname]['size'];
  18.                         if($filesize <= $maxfilesize )
  19.                         {
  20.                               $randomdigit = rand(0000,9999);
  21.  
  22.                               $newfilename = $randomdigit.$filename;
  23.                               $source = $_FILES[$conname]['tmp_name'];
  24.                               $target = "upload/project/".$newfilename;
  25.                               move_uploaded_file($source, $target);
  26.                                  $sql_update        =    "UPDATE project SET
  27.                                                         photo".$count." = '".$newfilename."',
  28.                                                         modified_date = now()    
  29.                                                     WHERE project_id    =    '".$str_project_id."' ";    
  30.                                 tep_db_query($sql_update, $conn);
  31.                         }
  32.                         else
  33.                         {
  34.                             echo $count." File is too big! 10MB limit! |";
  35.  
  36.                         }
  37.                     }
  38.                     else
  39.                     {
  40.                         echo " The file is not a supported type |";
  41.                     }
  42.                   }
  43.           $count = $count + 1;
  44.           }
  45.  
  46.  
If you have some sort of solution then please help me.

Thanks for read my post!
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,746
#2: Oct 1 '09

re: Image upload problem


Hey.

Are you getting any errors?
Can you describe exactly what happens. Anything we can use to help debug this.

My guess would be that this is a permission problem.
Are you sure your script has permission to write to the directory your images are supposed to be moved to?
Newbie
 
Join Date: Sep 2009
Posts: 4
#3: Oct 2 '09

re: Image upload problem


Hey buddy, I dont get any error but the update query executed fine! the new name has been successfully added to the database but not been uploaded to the desire location.
Newbie
 
Join Date: Sep 2009
Posts: 4
#4: Oct 2 '09

re: Image upload problem


Quote:

Originally Posted by Atli View Post

Hey.

Are you getting any errors?
Can you describe exactly what happens. Anything we can use to help debug this.

My guess would be that this is a permission problem.
Are you sure your script has permission to write to the directory your images are supposed to be moved to?

Hey Atli,

Thanks man, you rocks.

It is only a file permission problem nothing else. Thank you so much, you make my day!

Cheers!!!
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,746
#5: Oct 2 '09

re: Image upload problem


Your welcome.
I'm glad it worked out :-)
Reply

Tags
imageuploadscriptproblem