Geeks Talk

Prepare for your Next Interview




How can I upload a file by php coding

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 ...


Go Back   Geeks Talk > Web Development > PHP

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 04-04-2007
Expert Member
 
Join Date: Feb 2007
Posts: 1,279
Thanks: 0
Thanked 160 Times in 136 Posts
Geek_Guest is on a distinguished roadGeek_Guest is on a distinguished road
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
}
?>
Reply With Quote
The Following User Says Thank You to Geek_Guest For This Useful Post:
Sponsored Links
  #2 (permalink)  
Old 11-26-2007
Junior Member
 
Join Date: Nov 2007
Location: Poland
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
kapiatek is on a distinguished road
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
Reply With Quote
  #3 (permalink)  
Old 08-21-2008
Junior Member
 
Join Date: Aug 2008
Location: india
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
anujm1_1 is on a distinguished road
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.
Reply With Quote
Reply

  Geeks Talk > Web Development > PHP


Thread Tools
Display Modes


Similar Threads

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


All times are GMT -4. The time now is 04:11 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved