473,383 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Image upload problem

4
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!
Oct 1 '09 #1
4 1489
Atli
5,058 Expert 4TB
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?
Oct 1 '09 #2
Jeyush
4
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.
Oct 2 '09 #3
Jeyush
4
@Atli
Hey Atli,

Thanks man, you rocks.

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

Cheers!!!
Oct 2 '09 #4
Atli
5,058 Expert 4TB
Your welcome.
I'm glad it worked out :-)
Oct 2 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: lawrence | last post by:
I've been using the following function (yes, it is inelegant, what can I say, I wrote it a long time ago) to upload images. Haven't had a problem with it for at least a year, and I don't recall...
3
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a...
0
by: Paul Hamlington | last post by:
Hello, I've been programming in ASP for a little while now and quite an advanced user, but I have come across an unusual problem in which I need assistance. I have built my own image upload,...
2
by: Gary \(Girish\) | last post by:
Hello: I am using SA-FileUp to enable members to upload their product images to my ISP sever. When member uploaded a new image file, the file name is replaced with the member ID and the old file...
15
by: David Lozzi | last post by:
Howdy, I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders! Now I am making a public function that will take the...
2
by: prakharv | last post by:
Hi All, Below is the code which I am using to upload a jpeg file to the server. But the problem I am facing is that it is not copying the entire contents of the image file to the webserver and it...
4
by: Muddasir | last post by:
Hi.. i am having a strange problem.......the problem is i am trying to upload a file and to store it in db....when the file got stored in db...it got converted into black and white image and...
10
by: mishrarajesh44 | last post by:
hii all, I am facing a problem currently.. i have a script for image uploading and resizing.. the image uploading takes place properly for every size images.. but, the resizing works for...
1
by: sravani1 | last post by:
This code runs like when i submit the form it takes the image and displayed and top of the image a map will displayed. But actually i want that when i give the image it checks the location in the map...
1
by: chennaibala | last post by:
can any one send me mutiple image upload program and save the file name with extension in mysql table.we must cheak uploaded file type like bmp or any image file while uploading. i develop...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.