Jump to content

Recommended Posts

sorry....here is my form code....can someone tell me where im going wrong? Thank you in advance

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Untitled Document</title>

</head>

<table width="500" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">

<tr>

<form action="upload_rename_ac.php" method="post" enctype="multipart/form-data" name="form1" id="form1">

<td>

<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">

<tr>

<td><strong>Single File Upload </strong></td>

</tr>

<tr>

<td>Select file

<input name="ufile" type="file" id="ufile" size="50" /></td><br />

</tr>

<tr>

<td align="center"><input type="submit" name="Submit" value="Upload" /></td>

</tr>

</table>

</td>

</form>

</tr>

</table>

<body>

</body>

</html>

 

 

 

and here is my php code

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html><title>Submitting Details.....</title>

<?

$username="vecre0_tempU";

$password="auction";

$database="vecre0_templates";

 

 

$ufile=$_POST['ufile'];

$path=$_POST['path'];

 

mysql_connect(localhost,$username,$password);

@mysql_select_db($database) or die( "Unable to select database");

 

$query = "INSERT images VALUES ('','ufile','path')";

mysql_query($query);

 

mysql_close();

?>

<?php

$file_name = $HTTP_POST_FILES['ufile']['name'];

 

 

$random_digit=rand(000000,999999);

 

 

 

$new_file_name=$random_digit.$file_name;

 

 

$path= "upload/".$new_file_name;

if($ufile !=none)

{

if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path))

{

echo "Successful<BR/>";

 

 

echo "File Name :".$new_file_name."<BR/>";

echo "File Size :".$HTTP_POST_FILES['ufile']['size']."<BR/>";

echo "File Type :".$HTTP_POST_FILES['ufile']['type']."<BR/>";

echo $path;

}

else

{

echo "Error";

}

}

?>

Link to comment
https://forums.phpfreaks.com/topic/143952-upload-file/#findComment-755367
Share on other sites

Hi!

 

<?

$ufile=$_POST['ufile'];

$path=$_POST['path'];

 

$file_name = $HTTP_POST_FILES['ufile']['name'];

$random_digit=rand(000000,999999);

$new_file_name=$random_digit.$file_name;

$path= "upload/".$new_file_name;

 

?>

<?php

if($ufile !=none){

if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path)){

echo "Successful<BR/>";

mysql_connect(localhost,$username,$password);

@mysql_select_db($database) or die( "Unable to select database");

$query = "INSERT images VALUES ('','$file_name','$path')";

mysql_query($query);

}

}

mysql_close();

?>

 

Try it..

Link to comment
https://forums.phpfreaks.com/topic/143952-upload-file/#findComment-757958
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.