hi,
I tried to upload a file using php…it works fine but it not works while
upload a “firefox-3.5.3.tar.bz2” files(i mean tar.bz2 file)… could any one tell is it possible or not…
if it is… how?
Yes, it is possible.
Like any other file. No difference.
PHP manual is good place to start. However the code they have there is quite stupid.
HTML code should be shortened to
<form enctype="multipart/form-data" method="POST">
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>
But they have very useful thing there, http://ru2.php.net/manual/en/features.file-upload.errors.php
So, you should check for upload errors in your script and see what’s wrong with this particular file.
Mention your code here so that you can get proper answer.
here, my code…
<?php
if ($_POST[sub] == “submit”)
{
move_uploaded_file ($_FILES[‘file’][‘tmp_name’],
“/home/test/dload/”.$_FILES[‘file’] [‘name’]);
if($_FILES[‘file’] [‘error’] > 0)
{
echo ‘No file uploaded’;
}
else { $upload=‘yes’; }
} ?>
<form name=“form1” method=“post” enctype=“multipart/form-data”>
<table align=center >
<tr><td>File Name</td><td><input type=file name=file id=file size=30 style=‘border: thin solid #4682B4;’></td></tr>
<tr><td colspan=2 align=center><input type=submit name=sub value=submit>
</td></tr></table>
</form>
I made some modification with your code and its working:
<?php
if ($_POST['sub'] == "submit"){
move_uploaded_file ($_FILES['file']['tmp_name'],dirname(__FILE__).'/'.$_FILES['file'] ['name']);
if($_FILES['file'] ['error'] > 0){
echo 'No file uploaded';
}else {
echo 'Uploaded';
}
} ?>
<form name="form1" method="post" enctype="multipart/form-data">
<table align=center >
<tr><td>File Name</td><td><input type=file name=file id=file size=30 style='border: thin solid #4682B4;'></td></tr>
<tr><td colspan=2 align=center><input type=submit name=sub value=submit>
</td></tr></table>
</form>
It’s not working while uploading a file with (.tar.bz2) extension
Why don’t you check an error value?
I tried with the filename you provided: firefox-3.5.3.tar.bz2 and it was working.
if there is write permission on that upload folder?
it doen’t show any error after submitting the form…
It is you who ought to check an error! Are you programmer or just furniture behind computer?
type echo $_FILES[‘file’][‘error’] to print out error number.
yes it has write permission
Just a guess but the file might be to large, PHP defaults at 2 megs.
Oh yeah.
We are members of astrology club here.
And our job to guess, my a**.
Shrapnel_N5 always walk on his path
Check the upload error: http://www.php.net/manual/en/features.file-upload.errors.php
<?php
if ($_POST[sub] == "submit")
{
move_uploaded_file ($_FILES['file']['tmp_name'],
"/home/test/dload/".$_FILES['file'] ['name']);
if($_FILES['file'] ['error'] > 0)
{
echo 'ERROR: ';
switch ($_FILES['file']['error']) {
case UPLOAD_ERR_INI_SIZE:
echo 'The uploaded file exceeds the upload_max_filesize directive in php.ini.';
break;
case UPLOAD_ERR_FORM_SIZE:
echo 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.';
break;
case UPLOAD_ERR_PARTIAL:
echo 'The uploaded file was only partially uploaded.';
break;
case UPLOAD_ERR_NO_FILE:
echo 'No file was uploaded.';
break;
case UPLOAD_ERR_NO_TMP_DIR:
echo 'Missing a temporary folder. Introduced in PHP 4.3.10 and PHP 5.0.3.';
break;
case UPLOAD_ERR_CANT_WRITE:
echo 'Failed to write file to disk. Introduced in PHP 5.1.0.';
break;
case UPLOAD_ERR_EXTENSION:
echo 'File upload stopped by extension. Introduced in PHP 5.2.0.';
break;
default:
echo 'UNKNOWN error';
break;
}
}
else { $upload='yes'; }
} ?>
is dealing this way better?
if($_FILES['file'] ['error'] == 0)
{
move_uploaded_file ($_FILES['file']['tmp_name'], "/home/test/dload/".$_FILES['file']['name']);
}
else
{
//show proper error message here
}