File could not be moved

Need help with an engine or coding not on the list? Need help with a game or the website and forums here? Direct all questions here.
Post Reply
User avatar
vitinho444
Posts: 2825
Joined: Mon Mar 21, 2011 4:54 pm

File could not be moved

Post 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?
My Company Website: http://www.oryzhon.com

Skype: vpegas1234
User avatar
OldRod
Posts: 1321
Joined: Sun Sep 20, 2009 4:26 pm

Re: File could not be moved

Post 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.
User avatar
a_bertrand
Posts: 1537
Joined: Mon Feb 25, 2013 1:46 pm

Re: File could not be moved

Post by a_bertrand »

Could depends on the file size. PHP has a file size limit.
Creator of Dot World Maker
Mad programmer and annoying composer
User avatar
vitinho444
Posts: 2825
Joined: Mon Mar 21, 2011 4:54 pm

Re: File could not be moved

Post 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?
My Company Website: http://www.oryzhon.com

Skype: vpegas1234
User avatar
a_bertrand
Posts: 1537
Joined: Mon Feb 25, 2013 1:46 pm

Re: File could not be moved

Post by a_bertrand »

Creator of Dot World Maker
Mad programmer and annoying composer
User avatar
vitinho444
Posts: 2825
Joined: Mon Mar 21, 2011 4:54 pm

Re: File could not be moved

Post 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?
My Company Website: http://www.oryzhon.com

Skype: vpegas1234
User avatar
MikuzA
Posts: 395
Joined: Thu Aug 08, 2013 8:57 am

Re: File could not be moved

Post by MikuzA »

halls might be able to assist you on that, I guess?
Why so serious?

Business Intelligence, Data Engineering, Data Mining
PHP, HTML, JavaScript, Bash/KornShell, Python, C#, PL/SQL
MySQL, DB2, Oracle, Snowflake
Pentaho, DataStage, Matillion, Unity3D, Blender
User avatar
vitinho444
Posts: 2825
Joined: Mon Mar 21, 2011 4:54 pm

Re: File could not be moved

Post by vitinho444 »

Yap, it must be him, but some hosts don't allow to change the limit.. so let's see what happens..
My Company Website: http://www.oryzhon.com

Skype: vpegas1234
User avatar
hallsofvallhalla
Site Admin
Posts: 12031
Joined: Wed Apr 22, 2009 11:29 pm

Re: File could not be moved

Post 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.
User avatar
vitinho444
Posts: 2825
Joined: Mon Mar 21, 2011 4:54 pm

Re: File could not be moved

Post by vitinho444 »

You can set the server limit to 9999999 but the website one is the last defense and its editable through config.php.
My Company Website: http://www.oryzhon.com

Skype: vpegas1234
Post Reply

Return to “Advanced Help and Support”