GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 25-May-2009, 10:42
khushal_kkk's Avatar
khushal_kkk khushal_kkk is offline
Awaiting Email Confirmation
 
Join Date: Mar 2008
Posts: 50
khushal_kkk is an unknown quantity at this point

Upload Script


i want to add an upload feature to my website but am getting some issues following is my code i want the files which are uploaded by the users are getting stored in the "uploads" folder but the following code doesn't do that solve my issues


PHP Code:

<?php
if($_POST[upload] == "1")
{
$to = "uploads/".$_FILES['file']['name'];
move_uploaded_file($_FILES['file']['tmp_name'], $to);
echo "Uploaded";
}
?>
<form method="post" enctype="multipart/form-data">
<input type="hidden" name="upload" value="1"  />
<input type="file" name="file" />
<input type="submit" value="Upload" />
</form>
  #2  
Old 26-May-2009, 01:01
MisterChucker's Avatar
MisterChucker MisterChucker is offline
Junior Member
 
Join Date: Mar 2009
Location: Cyberspace, Earth
Posts: 53
MisterChucker is a jewel in the roughMisterChucker is a jewel in the roughMisterChucker is a jewel in the rough

Re: Upload Script


What issues are you having?

Does the folder named "uploads" exist?

The PHP Manual says, "Always use quotes around a string literal array index." On the second line of your code, the string "upload" is an index of the $_POST array. It should have quotes around it. That means that $_POST[upload] should be $_POST['upload'].

A better way to check that a file has been uploaded is to check that the $_FILES array is not empty by using the empty() function. Discard the hidden input.
 
 

Recent GIDBlogAccepted for Ph.D. program by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Web stats fcolor Web Design Forum 10 12-Jul-2007 09:48
Need Free Website Templates sam_dezine Web Design Forum 8 06-Sep-2006 04:25
Who Is A Web Designer ? alicehopkins Web Design Forum 1 13-Jun-2006 03:56
HTML Code amgujral Web Design Forum 0 07-Apr-2006 10:46
Upload Script da_bomb50 MySQL / PHP Forum 6 21-Mar-2005 12:01

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 22:39.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.