...

View Full Version : File upload issue



Jacobb123
05-10-2008, 02:11 AM
I am trying to upload files to my server via PHP but can only do it on certain files.

if I try articles.doc it uploads fine but if I do Azul Azul - La Bomba.mp3 it won't upload.

Here is my code:

$hz=$_POST['hz'];
if($hz=="eklez"){

$resimadi = $_FILES['userfile']['name'];
$uploadfile =$uploaddir.'/'. $resimadi;




move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile);
}


What could be the issue?

idalatob
05-10-2008, 02:29 PM
there could be a number of details:

1.) Check the phpinfo(); for details on:
max_execution_time
post_max_size
upload_max_filesize
If you are having problems because of your php settings, then use .htaccess or your php.ini file.
2.) Rename the file before using move_uploaded_file();

rafiki
05-10-2008, 05:16 PM
Do you realise how insecure that is? Hope thats not the whole script.

Jacobb123
05-10-2008, 06:06 PM
Yeah I realize it's insecure. I stripped it down to find the error. I will try renaming it and see if that works.

CFMaBiSmAd
05-10-2008, 06:20 PM
It is highly likely that an upload error is occurring (having something to do with the size of the file.) ALL code must test for any available error before attempting to use data. Read the discussion about the ['error'] element and the possible error values at this link - http://us2.php.net/manual/en/features.file-upload.php

I believe that link also mentions if you exceed the post_max_size setting that the $_FILES array will be null/not set (the $_POST array will be null/not set as well) and this condition needs to be tested for.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum