Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,471
There are 1082 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

File Upload Script Only Working Occasionally

Thread title: File Upload Script Only Working Occasionally
     
    Thread tools Search this thread Display Modes  
Prev Previous Post   Next Post Next
09-24-2012, 06:30 PM
#1
j-leist is offline j-leist
Status: I'm new around here
Join date: Sep 2012
Location: Leicester, England
Expertise: PHP, MySQL, HTML5, CSS3
Software: Dreamweaver!
 
Posts: 1
iTrader: 0 / 0%
 

j-leist is on a distinguished road

  Old  File Upload Script Only Working Occasionally

Hi,

Basically I have written a script to allow the user in the back end to upload pictures for the gallery. The script is supposed to upload the file to the server and then post the file name and info into the database.

It always uploads the file to the server without fail, however for some reason it only posts it to the database occasionally. Sometimes it works fine but 8 times out of 10 it uploads the file and thats it, the script is as follows.


PHP Code:
<?php 
 
 
//This is the directory where images will be saved 
 
$target "images/"
 
$target $target basename$_FILES['photo']['name']); 
 
 
//This gets all the other information from the form 
 
$name=$_POST['name']; 
 
$caption=$_POST['caption']; 
 
$pic=($_FILES['photo']['name']); 
 
$live=$_POST['live'];
 
 
//Connecting to the database
 
require_once('../Connections/tim.php'); 
 
 
 
//Writes the information to the database 
 
mysql_query("INSERT INTO `gallery` VALUES ('$name', '$caption', '$pic', '$live')") ; 
 
 
//Writes the photo to the server 
 
if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) 
 { 
 
 
//Tells you if its all ok 
 
echo "The file "basename$_FILES['uploadedfile']['name']). " has been uploaded successfully, press back to upload more"
 } 
 else { 
 
 
//Gives and error if its not 
 
echo "Sorry, there was a problem uploading your file."
 } 
 
?> 
 <a href="admin-gallery.php"> Back </a>

     


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed