473,322 Members | 1,314 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,322 software developers and data experts.

move_uploaded_file working fine locally but not in server

228 100+
I tested it in my local development machine but it doesnt work in live server.

move_uploaded_file just uploads jpg pictures of 60kb or less. It doesn't generate any error except my own custom error. Here is the function:

Expand|Select|Wrap|Line Numbers
  1. function UploadSingleImage($imageid,$maxsize,$putinto){
  2. //uploads a single file.
  3. $return=30;//if all success, the func returns 30
  4. global $photoerr;
  5. $kb=($maxsize/1024)." KB";
  6. if((!empty($_FILES["pic"])) && ($_FILES['pic']['error'] == 0)) {
  7.  
  8.   //Check if the file is JPEG image and it's size is less than maxsize
  9.   $filename = basename($_FILES['pic']['name']);
  10.   $ext = strtolower(substr($filename, strrpos($filename, '.') + 1));
  11. $phototype=$_FILES["pic"]["type"];
  12.   if (($ext == "jpg") && ( ($phototype == "image/jpeg") or ($phototype == "image/pjpeg")) && 
  13.     ($_FILES["pic"]["size"] <= $maxsize)) {
  14.  
  15.     //Determine the path to which we want to save this file
  16.       $newname =$putinto.$imageid.".jpg";
  17.  
  18.  
  19.         //Attempt to move the uploaded file to it's new place
  20.         if ((move_uploaded_file($_FILES['pic']['tmp_name'],$newname))) {
  21.           $return=30;
  22.         } 
  23.         else {
  24.         $photoerr="The photo is techinically accepted but there was an error placing it at its destination directory. Please contact the developers on how to fix this.";
  25.  
  26.            $return=32;
  27.         }
  28.  
  29.         } else {
  30.  
  31. $photoerr="The photo is not techinically accepted. It must be JPG and max $kb ($maxsize bytes).";
  32.      $return=32;
  33.   }
  34.  
  35. return $return;
  36. }//uploadFile
  37.  
  38.  
I call it this way:

Expand|Select|Wrap|Line Numbers
  1. UploadSingleImage(30,61440,PHOTOS);
  2. //ZENAPHOTOS is a constant in configuration file. set as follows briefly:
  3.  
  4. define('WWWFOLDER',$_SERVER['DOCUMENT_ROOT']."/");
  5. define('PHOTOS',WWWFOLDER.'pics/');
  6.  
  7.  
The configuration file is properly called.

Now, the error that is generated from running this script on the server is:

The photo is techinically accepted but there was an error placing it at its destination directory. Please contact the developers on how to fix this.

Any idea why it is not working on the server? The pics folder is permitted for me. I can upload/delete files from it via FTP.
Nov 25 '10 #1
1 5868
JKing
1,206 Expert 1GB
Try turning warnings on to give some insight as to why the file is not being moved.

Make sure you have the right directory.
Nov 25 '10 #2

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

Similar topics

0
by: J. Muenchbourg | last post by:
I'm cannot seem to get my request objects posted from a form on a previous page to show up on the page I'm posting to. When I try it locally on my IIS webserver, it works fine. But the form posting...
9
by: Larry Woods | last post by:
I have a site that works fine for days, then suddenly, I start getting ASP 0115 errors with an indication that session variables IN SEPARATE SESSIONS have disappeared! First, for background...
1
by: Dinesh | last post by:
Dear Friends, IIS is not working fine, sometime it works fine and sometime pages are taking lomg time. and same time FTP is not able to upload and doanload anything. It accepts username and...
3
by: Jason Shohet | last post by:
They are working fine on our w2k servers. On the remote site -- using 2003 server -- the controls don't occur until after the action is taken. We are doing a catch, so that we don't give the user...
1
by: Robert Bull | last post by:
I have an asp.net app that consumes a web service that is working fine on my local machine. I have put the service and the app on our web server. If I make a call to a function in the service that...
1
by: haisenthilk | last post by:
Hi I have a text box. I have to validate it only for numbers. There is another text box which depends on the value of the previous. so i should do the validation in onBlur().. If...
3
by: diya123 | last post by:
Hi, I trying to store a image path on session object.It is working fine on development server but not working on live.How to overcome this problem??
3
by: vishwa Ram | last post by:
Hi All, Please see my below code. my $dir = $ARGV; #Getting command line argument (path of the file) foreach $file (<$dir*.xml>) # Error here when i run exe only. In my above...
2
by: nudrat | last post by:
Hi, I am having problem in getting request.serverVariables("auth_user") when i place the pages in my server...locally in my pc it is working fine. what other changes i need to make in...
0
by: gpsharma | last post by:
Hi, Im using a httphandler to response another pdf file in case requested file not found. Its working fine in local development pc but not working in web server. Mapped .pdf as wild card mapping...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.