Page 1 of 1
problem with file upload using Apache/Linux
Posted: Sat Jul 01, 2006 3:49 am
by umezawasjitte
Im sorry if my problem is so basic... Ive tried scanning the tutorials I wasn't able to find anything, so I figured that everybody assumes that this topic is common knowledge.
I was just wondering what I need to do different in uploading a file using Apache/Linux, in terms of PHP code. I tried uploading in Windows using Apache and there wasn't any problem. Also, is there anything that has to be modified in the php.ini or httpd.conf?
Pls bear with me im a real noob.
Posted: Sat Jul 01, 2006 3:51 am
by Benjamin
File paths need to use / instead of \ slashes, there are no letter drives. What error are you receiving? Post your code please.
Posted: Sat Jul 01, 2006 8:27 am
by basdog22
You have to be aware of situations where :
1. Linux use case sensitive paths and files. eg : path1/subpath/ is not the same as : PaTh1/Subpath/
2. Safe mode settings in Linux works as supposed...

3. File permissions for the folder you are uploading to.
All of them can be found in the
manual

Posted: Mon Jul 03, 2006 5:25 am
by umezawasjitte
Pimptastic | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Thats my problem, there isn't any error, the file just can't be uploaded. Ive already checked the folder permissions, all the letter cases, and the file uploads configuration in the php.ini and they're ok.
So im thinking that there must be some other configuration that must be set in php.ini or httpd.conf. Actually, I didn't configure Apache or PHP thats why i suspected it immediately. But iv already tried tweaking it plenty of times and the problem is still there. Can anyone pls give me the right configuration settings on both the php.ini and httpd.conf for linux?
I've also observed that: $_FILES[$name]['tmp_name'] and the $_FILES[$name]['type'] are empty when I upload a file.
heres my code:
Code: Select all
function UploadFile($name) {
$cur_date = date('Y-m-d h:i:s');
$uid = GenerateId();
$query = "INSERT INTO upload_info (ID,file_name, file_size, file_type, upload_date)
VALUES ($uid,'{$_FILES[$name]['name']}',{$_FILES[$name]['size']},'{$_FILES[$name]['type']}',
'$cur_date')";
$result = @mysql_query($query);
if ($result){
$target_path = "../uploads/";
$target_path = $target_path . basename($_FILES[$name]['name']);
header("refresh:1; url='./index.php?tab=images&&page=index';");
if(move_uploaded_file($_FILES[$name]['tmp_name'], $target_path)) {
echo "<script type="text/javascript">alert('The file " . basename( $_FILES[$name]['name']). " has been uploaded')</script>";
} else {
echo "<script type="text/javascript">alert('There was an error uploading the file, please try again!')</script>";
}
} else {
echo 'Image upload, query failed';
}
}
Pimptastic | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]