Page 1 of 1

File could not be moved

Posted: Mon Nov 04, 2013 12:48 pm
by vitinho444
Hey guys, in the quest for release, I'm doing my best here at the Indie-Resource Resource Section website, but while testing a thing (the description string formatting, that is working btw) i found out a sort of a ... bug?

The thing is, i upload a resource, if i choose a picture, php says: "Hey cool picture, nhom nhom thanks" and its moved to the correct folder etc. Then i try give him a zip with some bullet holes textures, and he says the same: "Hey cool zip, so tiny, nhom nhom, hum delicious" and php moves it without any effort. But i tried doing ANOTHER zip with some drawings from my friend and it says "file couldn't be moved", this error is caused by this line:

Code: Select all

if(mkdir("images/resources/files/" . $time))
								{
									if(!move_uploaded_file($file_tmp, "images/resources/files/" . $time . "/" . $file_name))		//Move our file to our file dir
									{
										$errors[] = "File couldn't be moved!";
									}
								}
Why it works for some zips and for others it doesnt?

Anyone can help?

Re: File could not be moved

Posted: Mon Nov 04, 2013 6:44 pm
by OldRod
Is it possibly a problem with the file name (If you are sanitizing file names)? LIke a character that should be stripped out and isn't? Or a character that shouldn't be stripped out, but is?

Or when you append the time to it does it make the filename too long?

Something like that could be tripping you up.

Re: File could not be moved

Posted: Mon Nov 04, 2013 7:00 pm
by a_bertrand
Could depends on the file size. PHP has a file size limit.

Re: File could not be moved

Posted: Tue Nov 05, 2013 11:16 am
by vitinho444
@OldRod

It can't be the file being too long since the working zip is called "bullet holes" (the space will be deleted) and the not working is "peluche"

This is what im doing to the files before i move them:

Code: Select all

if($_FILES["file"])	//If we do have a file
							{
								$time = time();
								$hasFile = true;
								$file_name = time() . str_replace(' ', '', $_FILES["file"]["name"]);	//Get file name
								$file_ext = explode(".", $file_name);	//Get file ext
								$file_ext = end($file_ext);				//Get file ext
								$file_ext = strtolower($file_ext);		//Get file ext to lower case
								$file_tmp = $_FILES["file"]["tmp_name"];//Get file tmp location
								$file_size = $_FILES["file"]["size"];	//Get file size
							
								if(in_array($file_ext, $File_allowed_ext) === false)	//If our file ext is not allowed add error
								{
									$errors[] = "File extension not allowed!";
								}
								
								if($file_size > $MAX_FILE_SIZE)	//If file size is not allowed, add error
								{
									$errors[] = "File size must be under " . formatBytes($MAX_FILE_SIZE);
								}
								
								if(mkdir("images/resources/files/" . $time))
								{
									if(!move_uploaded_file($file_tmp, "images/resources/files/" . $time . "/" . $file_name))		//Move our file to our file dir
									{
										$errors[] = "File couldn't be moved!";
									}
								}
							}

@Alain
It may be the problem but i don't know how to fix it.. peluche.zip is 2.85MB and bullet holes is just 100KB so it may be.

I have a variable in the configs that holds the max file size, but apparently PHP doesn't care about it :/ Where can i change the limit?

Re: File could not be moved

Posted: Tue Nov 05, 2013 1:00 pm
by a_bertrand

Re: File could not be moved

Posted: Tue Nov 05, 2013 2:06 pm
by vitinho444
Yeah, the problem is that i dont have access to the configuration files in indie-resource.com domain... So i can't do that... And i thought that php would let me control it :(

My localhost was limiting at 2M so this was the error.. Thanks a lot guys ;)

PS: How am i supposed to control the limit in the indie-resource host?

Re: File could not be moved

Posted: Tue Nov 05, 2013 5:31 pm
by MikuzA
halls might be able to assist you on that, I guess?

Re: File could not be moved

Posted: Tue Nov 05, 2013 6:17 pm
by vitinho444
Yap, it must be him, but some hosts don't allow to change the limit.. so let's see what happens..

Re: File could not be moved

Posted: Tue Nov 05, 2013 8:53 pm
by hallsofvallhalla
you just need to create a .htaccess file and a config.ini file which I did. Try it now. Be careful about the limits as I do not want huge files on here.

Re: File could not be moved

Posted: Tue Nov 05, 2013 11:00 pm
by vitinho444
You can set the server limit to 9999999 but the website one is the last defense and its editable through config.php.