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
- function UploadSingleImage($imageid,$maxsize,$putinto){
- //uploads a single file.
- $return=30;//if all success, the func returns 30
- global $photoerr;
- $kb=($maxsize/1024)." KB";
- if((!empty($_FILES["pic"])) && ($_FILES['pic']['error'] == 0)) {
- //Check if the file is JPEG image and it's size is less than maxsize
- $filename = basename($_FILES['pic']['name']);
- $ext = strtolower(substr($filename, strrpos($filename, '.') + 1));
- $phototype=$_FILES["pic"]["type"];
- if (($ext == "jpg") && ( ($phototype == "image/jpeg") or ($phototype == "image/pjpeg")) &&
- ($_FILES["pic"]["size"] <= $maxsize)) {
- //Determine the path to which we want to save this file
- $newname =$putinto.$imageid.".jpg";
- //Attempt to move the uploaded file to it's new place
- if ((move_uploaded_file($_FILES['pic']['tmp_name'],$newname))) {
- $return=30;
- }
- else {
- $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.";
- $return=32;
- }
- } else {
- $photoerr="The photo is not techinically accepted. It must be JPG and max $kb ($maxsize bytes).";
- $return=32;
- }
- }
- return $return;
- }//uploadFile
Expand|Select|Wrap|Line Numbers
- UploadSingleImage(30,61440,PHOTOS);
- //ZENAPHOTOS is a constant in configuration file. set as follows briefly:
- define('WWWFOLDER',$_SERVER['DOCUMENT_ROOT']."/");
- define('PHOTOS',WWWFOLDER.'pics/');
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.