Prepare for your Next Interview
This is a discussion on How can I upload a file by php coding within the PHP forums, part of the Web Development category; Question asked by visitor Arnab How can I upload a file by php coding? I have been try it by xamapp .But the code is running local machine . but when ...
|
|||
|
How can I upload a file by php coding
Question asked by visitor Arnab
How can I upload a file by php coding? I have been try it by xamapp .But the code is running local machine . but when I upload the code on the other server some where the code is not running. my code as : *************** if($_REQUEST['Submit']=='Submit') { if (($_FILES['fupload']['type'] == "image/gif")|| ($_FILES['fupload']['type'] == "image/jpeg")||($_FILES['fupload']['type'] == "image/pjpeg")){ $archive_dir="thum_imges"; echo $userfile=$_POST['fupload']; echo " "; echo $userfiled=$_FILES['fupload']['tmp_name']; echo " "; echo $filename=$_FILES['fupload']['name']; echo " "; $filenm=basename($filename); // $up= copy($userfiled,"$archive_dir/$filenm") ; $up= move_uploaded_file($userfiled,"$archive_dir/$filenm") ; echo " up = $up "; }//End of file check if } ?> |
| The Following User Says Thank You to Geek_Guest For This Useful Post: | ||
| Sponsored Links |
|
|||
|
Re: How can I upload a file by php coding
first of all, try to avoid using REQUEST variable,
it is too "heavy", i mean in REQUEST You have POST and GET so try to send form, especially files, only using POST ////// second thing, try to debug using var_dump and try to find out, if those variables really exists if the $_REQUEST['Submit']=='Submit' if(isset($_REQUEST['Submit']) && $_REQUEST['Submit'] == 'Submit') { //here do You code } else { //echo "The form was incorrectly sent"; } //// 3rd problem which can occour, that You haven't granted enough privileges for write access /// 4rd problem, on many servers the global variables are turned off, Hope You find those usefull Charles |
|
|||
|
Re: How can I upload a file by php coding
we can upload a file using php.
if(is_uploaded_file($_FILES['yourfilename']['tmp_name'], pathname) { echo "file is already uploaded "; move_uploaded_file($_FILES['yourfilename']['tmp_name'], pathname) { echo "replace the previous file from new file(having the same name) "; } } else { echo "file is not uploaded so i need to upload a file first time"; } and if u are upload a file first time . u have to write enctype='multiple/form-data' inside a form tag. BY ANUJ MAHESHWARI Last edited by anujm1_1 : 08-21-2008 at 05:17 AM. |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Frigate3 File Manager: highly configurable and convenient file management environment | JobHelper | Geeks Lounge | 0 | 03-30-2007 02:30 PM |
| Upload files | bvani | PERL | 0 | 03-21-2007 12:03 PM |
| Upload / Download a file to the server | parthaspaul | Oracle | 0 | 03-14-2007 09:42 PM |
| Unable Upload Image for my signature | kalayama | Suggestions & Feedback | 0 | 12-22-2006 01:56 AM |
| How do one upload image? | jamesravid | Suggestions & Feedback | 11 | 12-11-2006 08:11 AM |