Jump to content

PHP Upload adding underscore to the spaces (filename) how to?


Darkwoods

Recommended Posts

hey.. when i upload a file named with spaces like for example ''file name.jpg'' it does not send the full name to mysql it just send 'file' plus  to make a link to it it wont work because no % in spaces so the best thing is to put underscore in spaces but how what are codes thanks :)

 

herer is the upload page

<?php
include "inc/header.php";
  
   $id = $_GET['id'];
   if(isset($_POST['submit']))
  {

//global variables
include "inc/variables.php";
$name=$_POST['name'];
$pic=($_FILES['downl']['name']);


	$result = mysql_query("UPDATE contents SET title_en='$title_en', title_ar='$title_ar', en='$en', ar='$ar', cat='$cat', downl='$pic', name='$name' WHERE id='$id' ",$connect);
	  echo "<b>Your post have been added successfully";
          echo "<meta http-equiv=Refresh content=2;url=index.php>";
}

//the directory where images will be saved
$target = "uploads/downloads/";
$target = $target . basename( $_FILES['downl']['name']);


//Writes the filedw to the server
if(move_uploaded_file($_FILES['downl']['tmp_name'], $target))
{

//Tells you if it the upload were done
echo "The file ". basename( $_FILES['downl']['name']). " has been uploaded, and your information has been added to the directory";
}

        $result = mysql_query("SELECT * FROM contents WHERE id='$id' ",$connect);
        while($row = mysql_fetch_assoc($result))
             {
			$title_ar = $row["title_ar"];
                $title_en = $row["title_en"];
                $en = $row["en"];
                $ar= $row["ar"];
                $cat= $row["cat"];
			$name= $row["name"];
			$pic= $row["downl"]; ?>
                

      <h3>:: Edit Uploaded Software</h3>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']  ?>?id=<?php echo $row['id']?>"  enctype="multipart/form-data">
<input type="hidden" name="id" value="<?php echo $row['id']?>">
  <table border="0" cellspacing="4" cellpadding="4">
  <tr>
    <td>Select Category:</td>
    <td colspan="2"><select name="cat"><option value="3">Download</option></select> 
    </td>
  </tr>
    <tr>
    <td>Title:</td>
    <td ><input name="title_en" size="40" maxlength="255" value="<?php echo $title_en; ?>"></td>
    <td><input name="title_ar" size="40" maxlength="255" value="<?php echo $title_ar; ?>"></td>
  </tr>
    <tr>
      <td>Content:</td>
      <td><textarea name="en"  rows="7" cols="30"><?php echo $en; ?></textarea></td>
      <td><textarea name="ar" rows="7" cols="30"><?php echo $ar; ?></textarea></td>
    </tr>
        <tr>
    <td>Software:</td>
    <td><input name="name" size="40" maxlength="255" value="<?php echo $name; ?>"> 
    <td><input type="file" name="downl"> 
</td>
  </tr>
    <tr>
      <td colspan="3" class="submit"><input type="submit" name="submit" value="Add"></td>
      
    </tr>
</table>    
</form>
<?php  } 

include "inc/footer.php"; ?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.