Hi everyone,

I'm using move_upload_function for uploading file. I works fine on localhost but, it doesn't work on live server.

Thank in advance..

Member Avatar for diafol

show your code. Is the destination directory writable?

if ($_FILES['image']['name'] != "")
		{
			$ext = explode(".",$_FILES['image']['name']);
			$extension = strtolower($ext[1]);
			
			
			if ($extension =="jpg" || $extension =="jpeg" || $extension =="png" || $extension == "gif")
			{
				include("class/resize-class.php");
				
				$action = "auto";
				$width_thumb = 148;//output for portrait 119px && for landscape it is 148px
				$height_thumb = 148;//output for portrait 148px && for landscape it is 128px
				$width_medium = 340;//output for portrait 273px && for landscape it is 340px
				$height_medium = 340;//output for portrait 340px && for landscape it is 296px	
				
				 $file_name = time().".".$extension;
				$target_path = './orig_img/'.$file_name;				
				
				
				
						if(move_uploaded_file($_FILES['image']['tmp_name'], $target_path))
						{
							echo "Image Uploaded Successfully!!";
							
						}//EO if(move_uploaded_file($_FILES['upload']['tmp_name'], $target_orig))
						else
						{
							$error_msg[] = "Problem Occured While uploading image";
							
						}
				
			}//EO if ($extension =="jpg" || $extension =="jpeg" || $extension =="png" || $extension == "gif")
			else
			{
				$error_msg[] = "Please Upload only jpg, jpeg, png or gif formats for image";

			}			
			
			
		}//EO if ($_FILES['image']['name'] != "")

check if the directory orig_img/ on your server is writeble by apache

Thx my freind. The folder was not having write permission. I gave read, write, execute permission to all options i.e. Owner Permissions, Group Permissions & Public Permissions

Now, its working. You saved my day. Thanks a lot

Member Avatar for diafol

//EDIT

Solution posted as I was typing:

show your code. Is the destination directory writable?

As I thought.

Please mark as solved.

Thx my freind. The folder was not having write permission. I gave read, write, execute permission to all options i.e. Owner Permissions, Group Permissions & Public Permissions

if you set write permisons to public that mean that ANYONE can write files to dir.
You don't want that.

You mean that, I should give write permission to only Owner & Group?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.