Also try to keep all the images folder name small caps and no spacing between 2 words, use _ . Ex: uploaded_images ! check :in html form, "file field name" --- In php-objects@xxxxxxxxxxxxxxx, kranthi <kranthi117@...> wrote: > > seems u hav an error in the HTML page it self.... print_r() will be a very > useful debugging tool in many cases.. > Kranthi. > > > On Thu, Nov 6, 2008 at 13:04, Udaya kumar <udayakumaar@...> wrote: > > > Hi Sana, > > > > What is the value of $_FILE['upload']['error']? > > > > Check your form has multipart-form enctype attribute and MAXFILESIZE hidden > > field. Also check the filesize and php.ini max_upload_filesize value. > > > > Thanks & Regards > > Udayakumar Sarangapani > > Sr. PHP Developer > > CompIndia Infotech Pvt. Ltd. > > Chennai. > > > > "Science is nothing but logic..." > > > > ________________________________ > > > > From: Sana Alamgeer <sanalmgr47@... <sanalmgr47%40yahoo.com>> > > To: php-objects@xxxxxxxxxxxxxxx <php-objects%40yahoogroups.com> > > Sent: Thursday, 6 November, 2008 1:35:04 AM > > Subject: RE: File - UPLOAD > > > > here is the code. > > please make corrections if any.... > > <?php > > /* > > ---Description - > > The Super Global Variable $_FILES is used in PHP 4.x.x. > > $_FILES['upload' ]['size'] ==> Get the Size of the File in Bytes. > > $_FILES['upload' ]['tmp_name' ] ==> Returns the Temporary Name of the File. > > > > $_FILES['upload' ]['name'] ==> Returns the Actual Name of the File. > > $_FILES['upload' ]['type'] ==> Returns the Type of the File. > > So if I uploaded the file 'test.doc', the $_FILES['upload' ]['name'] > > would be 'phptut.doc' and $_FILES['upload' ]['type'] would be 'application/ > > msword'. > > --*/ > > > > // $_FILES['filetouplo ad'] is the value of // > > // file field from the form. <input type="file" name="filetoupload" > // > > // this is the upload dir where files will go. > > //Don't remove the / > > //Chmod it (777) > > $upload_dir = "C:\wamp\www\ Upload File\Uploaded Documents"; //change to > > whatever you want. > > //51200 bytes = 50KB > > $size_bytes = 51200; //File Size in bytes (change this value to fit your > > need) > > $extlimit = "no"; //Do you want to limit the extensions of files uploaded > > (yes/no) > > $limitedext = array(".gif" ,".jpg"," .jpeg",". png",".txt" ,".nfo"," > > .doc",".rtf" ,".htm"," .dmg",".zip" ,".rar"," .gz",".exe" ); //Extensions > > you want files uploaded limited to. also you can use: //array(".gif" > > ,".jpg"," .jpeg",". png",".txt" ,".nfo"," .doc",".rtf" ,".htm"," > > .dmg",".zip" ,".rar"," .gz",".exe" ); > > //check if the directory exists or not. > > if (!is_dir("$upload_ dir")) { > > die ("The directory <b>($upload_ dir)</b> doesn't exist"); > > } > > //check if the directory is writable.. > > if (!is_writeable( "$upload_ dir")){ > > die ("The directory <b>($upload_ dir)</b> is NOT writable, Please CHMOD > > (777)"); > > } > > > > if($uploadform) // if you clicked the (Upload File) button. "If you > > submitted the form" then upload the file. > > {//begin of if($uploadform) . > > > > //check if no file selected. > > if (!is_uploaded_ file($_FILES[ 'filetoupload' ]['tmp_name' ])) > > { > > echo "Error: Please select a file to upload!. <br>»<a href=\"$_SERVER[ > > PHP_SELF] \">back</ a>"; > > exit(); //exit the script and don't do anything else. > > } > > //Get the Size of the File > > $size = $_FILES['filetouplo ad']['size' ]; > > //Make sure that file size is correct > > if ($size > $size_bytes) > > { > > $kb = $size_bytes / 1024; > > echo "File Too Large. File must be <b>$kb</b> KB. <br>»<a href=\"$_SERVER[ > > PHP_SELF] \">back</ a>"; > > exit(); > > } > > //check file extension > > $ext = strrchr($_FILES[ 'filetoupload' ][name],' .'); > > if (($extlimit == "yes") && (!in_array($ ext,$limitedext) )) { > > echo("Wrong file extension. "); > > exit(); > > } > > // $filename will hold the value of the file name submetted from the form. > > $filename = $_FILES['filetouplo ad']['name' ]; > > // Check if file is Already EXISTS. > > if(file_exists( $upload_dir. $filename) ){ > > echo "Oops! The file named <b>$filename </b>already exists. <br>»<a > > href=\"$_SERVER[ PHP_SELF] \">back</ a>"; > > exit(); > > } > > //Move the File to the Directory of your choice > > //move_uploaded_ file('filename' ,'destination' ) Moves afile to a new > > location. > > if (move_uploaded_ file($_FILES[ 'filetoupload' ]['tmp_name' ],$upload_ > > dir.$filename) ) { > > //tell the user that the file has been uploaded and make him alink. > > echo "File (<a href=$upload_ dir$filename> $filename< /a>) uploaded! > > <br>»<a href=\"$_SERVER[ PHP_SELF] \">back</ a>"; > > exit(); > > } > > // print error if there was a problem moving file. > > else > > { > > //Print error msg. > > echo "There was a problem moving your file. <br>»<a href=\"$_SERVER[ > > PHP_SELF] \">back</ a>"; > > exit(); > > } > > > > }//end of if($uploadform) . > > // If the form has not been submitted, display it! > > else > > {//begin of else > > > > ?> > > <br> > > <h3>::Browse a File to Upload:</h3> > > <i>- Allowed Extensions:< /i> > > <b> > > <?php > > // print the file extensions > > for($i=0;$i< count($limitedex t);$i++) > > { > > if (($i<>count( $limitedext) -1))$commas= ", ";else $commas=""; > > list($key,$value) =each($limitedex t); > > echo $value.$commas; > > } > > ?> > > </b> > > > > <br> > > <i>- Max File Size</i> = <b><?php echo $size_bytes / 1024; ?> KB </b> > > <br> > > <form method="post" enctype="multipart/ form-data" action="<?php echo > > $PHP_SELF ?>"> > > <br> > > <input type="file" name="filetoupload" ><br> > > <input type="hidden" name="MAX_FILE_ SIZE" value="<?echo $size_bytes; ?>"> > > <br> > > <input type="Submit" name="uploadform" value="Upload File"> > > </form> > > <?php > > > > }//end of else > > > > // Here is the most interesting part. > > // it views the directory contents.... .i'll disscuss next version. (ver > > 2.0) > > echo "<br><br><hr> <br><b>Current Uploaded Files:</b><br> "; > > ?> > > <table border="1" bordercolor= "#C0C0C0" cellspacing= "1"> > > <tr> > > <td bgcolor="#F4F4F4" >File Name</td> > > <td bgcolor="#F4F4F4" >File Size</td> > > </tr> > > <?php > > $rep=opendir( $upload_dir) ; > > while ($file = readdir($rep) ) { > > if($file != '..' && $file !='.' && $file !=''){ > > if (!is_dir($file) ){ > > // print the file name and then make a link. > > echo "<tr><td> <a href=\"$upload_ dir$file\ " target=_blank> > > <img src=$upload_ dir$file border=0 width=100> > > </a> > > </td>"; > > > > #----------- -begin of file size. > > //print the file size. > > $file_size = filesize($upload_ dir."".$file) ; > > if ($file_size >= 1048576) > > { > > $show_filesize = number_format( ($file_size / 1048576),2) . " MB"; > > } > > elseif ($file_size >= 1024) > > { > > $show_filesize = number_format( ($file_size / 1024),2) . " KB"; > > } > > elseif ($file_size >= 0) > > { > > $show_filesize = $file_size . " bytes"; > > } > > else > > { > > $show_filesize = "0 bytes"; > > } > > echo "<td> $show_filesize </td></tr>"; > > #----------- -end of file size. > > } > > } > > } > > closedir($rep) ; > > clearstatcache( ); > > ?> > > </table> > > > > SanaAlamgeer > > > > --- On Thu, 10/30/08, Sana Alamgeer <sanalmgr47@yahoo. com> wrote: > > > > From: Sana Alamgeer <sanalmgr47@yahoo. com> > > Subject: RE: File - UPLOAD > > To: "Muhammad Sohail Khan" <sohail_meet@ hotmail.com> > > Date: Thursday, October 30, 2008, 6:52 PM > > > > here is the code. > > <?php > > /* > > ---Description - > > The Super Global Variable $_FILES is used in PHP 4.x.x. > > $_FILES['upload' ]['size'] ==> Get the Size of the File in Bytes. > > $_FILES['upload' ]['tmp_name' ] ==> Returns the Temporary Name of the File. > > > > $_FILES['upload' ]['name'] ==> Returns the Actual Name of the File. > > $_FILES['upload' ]['type'] ==> Returns the Type of the File. > > So if I uploaded the file 'test.doc', the $_FILES['upload' ]['name'] > > would be 'phptut.doc' and $_FILES['upload' ]['type'] would be 'application/ > > msword'. > > --*/ > > > > // $_FILES['filetouplo ad'] is the value of // > > // file field from the form. <input type="file" name="filetoupload" > // > > // this is the upload dir where files will go. > > //Don't remove the / > > //Chmod it (777) > > $upload_dir = "C:\wamp\www\ Upload File\Uploaded Documents"; //change to > > whatever you want. > > //51200 bytes = 50KB > > $size_bytes = 51200; //File Size in bytes (change this value to fit your > > need) > > $extlimit = "no"; //Do you want to limit the extensions of files uploaded > > (yes/no) > > $limitedext = array(".gif" ,"..jpg"," .jpeg",". png",".txt" ,".nfo"," > > .doc",".rtf" ,".htm"," .dmg",".zip" ,".rar"," .gz",".exe" ); //Extensions > > you want files uploaded limited to. also you can use: //array(".gif" > > ,".jpg"," .jpeg",". png",".txt" ,".nfo"," .doc",".rtf" ,".htm"," > > .dmg",".zip" ,".rar"," .gz",".exe" ); > > //check if the directory exists or not. > > if (!is_dir("$upload_ dir")) { > > die ("The directory <b>($upload_ dir)</b> doesn't exist"); > > } > > //check if the directory is writable. > > if (!is_writeable( "$upload_ dir")){ > > die ("The directory <b>($upload_ dir)</b> is NOT writable, Please CHMOD > > (777)"); > > } > > > > if($uploadform) // if you clicked the (Upload File) button. "If you > > submitted the form" then upload the file. > > {//begin of if($uploadform) . > > > > //check if no file selected. > > if (!is_uploaded_ file($_FILES[ 'filetoupload' ]['tmp_name' ])) > > { > > echo "Error: Please select a file to upload!. <br>»<a href=\"$_SERVER[ > > PHP_SELF] \">back</ a>"; > > exit(); //exit the script and don't do anything else. > > } > > //Get the Size of the File > > $size = $_FILES['filetouplo ad']['size' ]; > > //Make sure that file size is correct > > if ($size > $size_bytes) > > { > > $kb = $size_bytes / 1024; > > echo "File Too Large. File must be <b>$kb</b> KB. <br>»<a href=\"$_SERVER[ > > PHP_SELF] \">back</ a>"; > > exit(); > > } > > //check file extension > > $ext = strrchr($_FILES[ 'filetoupload' ][name],' .'); > > if (($extlimit == "yes") && (!in_array($ ext,$limitedext) )) { > > echo("Wrong file extension. "); > > exit(); > > } > > // $filename will hold the value of the file name submetted from the form. > > $filename = $_FILES['filetouplo ad']['name' ]; > > // Check if file is Already EXISTS. > > if(file_exists( $upload_dir. $filename) ){ > > echo "Oops! The file named <b>$filename </b>already exists. <br>»<a > > href=\"$_SERVER[ PHP_SELF] \">back</ a>"; > > exit(); > > } > > //Move the File to the Directory of your choice > > //move_uploaded_ file('filename' ,'destination' ) Moves afile to a new > > location. > > if (move_uploaded_ file($_FILES[ 'filetoupload' ]['tmp_name' ],$upload_ > > dir.$filename) ) { > > //tell the user that the file has been uploaded and make him alink. > > echo "File (<a href=$upload_ dir$filename> $filename< /a>) uploaded! > > <br>»<a href=\"$_SERVER[ PHP_SELF] \">back</ a>"; > > exit(); > > } > > // print error if there was a problem moving file. > > else > > { > > //Print error msg. > > echo "There was a problem moving your file. <br>»<a href=\"$_SERVER[ > > PHP_SELF] \">back</ a>"; > > exit(); > > } > > > > }//end of if($uploadform) . > > // If the form has not been submitted, display it! > > else > > {//begin of else > > > > ?> > > <br> > > <h3>::Browse a File to Upload:</h3> > > <i>- Allowed Extensions:< /i> > > <b> > > <?php > > // print the file extensions > > for($i=0;$i< count($limitedex t);$i++) > > { > > if (($i<>count( $limitedext) -1))$commas= ", ";else $commas=""; > > list($key,$value) =each($limitedex t); > > echo $value.$commas; > > } > > ?> > > </b> > > > > <br> > > <i>- Max File Size</i> = <b><?php echo $size_bytes / 1024; ?> KB </b> > > <br> > > <form method="post" enctype="multipart/ form-data" action="<?php echo > > $PHP_SELF ?>"> > > <br> > > <input type="file" name="filetoupload" ><br> > > <input type="hidden" name="MAX_FILE_ SIZE" value="<?echo $size_bytes; ?>"> > > <br> > > <input type="Submit" name="uploadform" value="Upload File"> > > </form> > > <?php > > > > }//end of else > > > > // Here is the most interesting part. > > // it views the directory contents.... .i'll disscuss next version. (ver > > 2.0) > > echo "<br><br><hr> <br><b>Current Uploaded Files:</b><br> "; > > ?> > > <table border="1" bordercolor= "#C0C0C0" cellspacing= "1"> > > <tr> > > <td bgcolor="#F4F4F4" >File Name</td> > > <td bgcolor="#F4F4F4" >File Size</td> > > </tr> > > <?php > > $rep=opendir( $upload_dir) ; > > while ($file = readdir($rep) ) { > > if($file != '..' && $file !='.' && $file !=''){ > > if (!is_dir($file) ){ > > // print the file name and then make a link. > > echo "<tr><td> <a href=\"$upload_ dir$file\ " target=_blank> > > <img src=$upload_ dir$file border=0 width=100> > > </a> > > </td>"; > > > > #----------- -begin of file size. > > //print the file size. > > $file_size = filesize($upload_ dir."".$file) ; > > if ($file_size >= 1048576) > > { > > $show_filesize = number_format( ($file_size / 1048576),2) . " MB"; > > } > > elseif ($file_size >= 1024) > > { > > $show_filesize = number_format( ($file_size / 1024),2) . " KB"; > > } > > elseif ($file_size >= 0) > > { > > $show_filesize = $file_size . " bytes"; > > } > > else > > { > > $show_filesize = "0 bytes"; > > } > > echo "<td> $show_filesize </td></tr>"; > > #----------- -end of file size. > > } > > } > > } > > closedir($rep) ; > > clearstatcache( ); > > ?> > > </table> > > > > SanaAlamgeer > > > > --- On Thu, 10/30/08, Muhammad Sohail Khan <sohail_meet@ hotmail.com> > > wrote: > > > > From: Muhammad Sohail Khan <sohail_meet@ hotmail.com> > > Subject: RE: File - PHPClassesFeatureRe quests.txt > > > > To: php-objects@ yahoogroups. com > > Date: Thursday, October 30, 2008, 5:43 PM > > > > Hi Sana, > > Sory for late response. Here is the code. just copy it and change the file > > name. nothing else. > > > > //__________ _________ _________ _________ ______ > > <?php > > if (isset($_POST[ 'skDownload' ])) { > > $filename = 'sohail_cv.doc' ; > > header("Pragma: public"); // required > > header("Expires: 0"); > > header("Cache- Control: must-revalidate, post-check=0, pre-check=0" ); > > header("Cache- Control: private",false) ; // required for certain browsers > > header("Content- Type: application/ msword"); > > // change, added quotes to allow spaces in filenames, by Rajkumar Singh > > header("Content- Disposition: attachment; filename=\"" .basename( > > $filename) ."\";" ); > > header("Content- Transfer- Encoding: binary"); > > header("Content- Length: ".filesize($ filename) ); > > readfile("$filename "); > > exit(); > > } else { > > echo "<form name='frm1' method='post' > > > <input type='submit' name='skDownload' value='Download Me'> > > </form>"; > > } > > ?> > > > > You can test it live here... > > > > http://www.zoajmake rs.com/downloadM e.php > > > > //__________ _________ _________ _________ ______ > > > > cheer up > > :) > > Muhammad Sohail Khan > > > > Software Engineer > > > > Cell: +92 333 575 9991 > > > > To: php-objects@ yahoogroups. com > > From: sanalmgr47@yahoo. com > > Date: Thu, 30 Oct 2008 09:03:38 -0700 > > Subject: Re: File - PHPClassesFeatureRe quests.txt > > > > hello all, > > > > im facing the problem in making a download link behind a button.what should > > be the code? > > > > A link also doesn't work behind the button to go back to the page mentioned > > in link. Please Help Me. > > > > SanaAlamgeer > > > > --- On Wed, 10/29/08, Sana Alamgeer <sanalmgr47@ yahoo. com> wrote: > > > > From: Sana Alamgeer <sanalmgr47@ yahoo. com> > > > > Subject: Re: File - PHPClassesFeatureRe quests.txt > > > > To: php-objects@ yahoogroups. com > > > > Date: Wednesday, October 29, 2008, 5:30 PM > > > > hello all, > > > > im facing the problem in making a download link behind a button.what should > > be the sode? > > > > A link also doesn't work behind the button. Please Help Me. > > > > SanaAlamgeer > > > > --- On Sun, 10/19/08, php-objects@ yahoogroups. com <php-objects@yahoogroups. com> wrote: > > > > From: php-objects@ yahoogroups.. com <php-objects@ yahoogroups. com> > > > > Subject: File - PHPClassesFeatureRe quests.txt > > > > To: php-objects@ yahoogroups. com > > > > Date: Sunday, October 19, 2008, 11:39 AM > > > > Hello, > > > > This is just a reminder messages to let you know as subscriber of the > > php-objects > > > > mailing list you may be interested about the new site where you may submit > > new > > > > feature requests or bug reports about the PHP Classes. > > > > The site URL is http://bugs. phpclasses. org/ . > > > > If you would like to keep track or discuss the feature requests or bug > > reports, > > > > you can join the PHP Classes Bugs mailing list by either sending an empty > > message > > > > to phpclasses-bugs- subscribe@ yahoogroups. com or by accessing the list > > page at: > > > > http://groups. yahoo.com/ group/phpclasses -bugs > > > > Manuel Lemos > > > > moderator of php-objects list > > > > [Non-text portions of this message have been removed] > > > > [Non-text portions of this message have been removed] > > > > ____________ _________ _________ _________ _________ _________ _ > > Stay up to date on your PC, the Web, and your mobile phone with Windows > > Live. > > http://clk.atdmt. com/MRT/go/ msnnkwxp10200931 85mrt/direct/ 01/ > > > > [Non-text portions of this message have been removed] > > > > [Non-text portions of this message have been removed] > > > > Add more friends to your messenger and enjoy! Go to > > http://messenger.yahoo.com/invite/ > > > > [Non-text portions of this message have been removed] > > > > > > > > > [Non-text portions of this message have been removed] >