Jump to content


This topic is now archived and is closed to further replies.


Uploading a php file

Recommended Posts

I want to upload the file artist_name.php to a server via a CMS
and also get its name into a field in the MYSQL database running
on that machine.

When I do the following the filename comes into
the database field, but the file itself is not uploaded to the server

Can someone help me please, how to have the file itself
uploaded also to the server.

Many thanks in advance!

This is a tiny piece of the code:




  $object_SQL_insert="INSERT INTO artists (artist_name_file) VALUES ('$artist_name_file')";



This code is part of the file where the form is:

<form action=artists.php method=post enctype="multipart/form-data">
  <table width="300" border="0" cellspacing="3" cellpadding="3">
  <tr valign="middle" bgcolor="F9F9F9">
<td class="stdtextconfig" width="122">File</td>
<td class="stdtextconfig" width="564">
<input type="file" name="artist_name_file" size="45"></td>
  <tr bgcolor="F9F9F9">
      <td colspan="2">
      <div align="center">
      <input type="hidden" name="action" value="insert">
      <input type="submit" name="Submit" value="OK">

Share this post

Link to post
Share on other sites

  $object_SQL_insert="INSERT INTO artists (artist_name_file) VALUES ('$artist_name_file')";

You could easily know a lot more than I do, but here's how I'd do it:

$a = $_POST['artist_name_file'];
if ($a)  {
$query = "INSERT INTO artists (artist_name_file) VALUES ('$a')";
$result = mysql_query ($query);
$aid = mysql_insert_id();          // Get the article ID.
                if ($aid > 0) {            // New article has been added.
echo ("The artist's name posted successfully into artists as $a at id $aid") <br />");
                } else {
                              echo "Something went wrong!";
} else {

echo 'The variable $a didn't get a value';

Share this post

Link to post
Share on other sites
Thanks for your time and reply!!
But that is not what I meant.

I finally found the solution:

  if($_FILES['artist_name_file']['size']>0)    {

  $dest="../" . $name_file;

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.