i actually want a user to select a file to upload to my webspace , and while uploading it is renamed and at end it will display a url to the user which contains php variables ( (depends on the file name) .. i have made a form (for the user to select it) and a php file(which will rename and upload it)..the code is as follows-


FORM :-

<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>
</tr>
<tr>
<td align="center"><input type="submit" name="Submit" value="Upload" /></td>
</tr>
</table>
</td>
</form>
</tr>
</table>

PHP FILE : -

<?php

// Your file name you are uploading 
$file_name = $HTTP_POST_FILES['ufile']['name'];

// random 4 digit to add to our file name 
// some people use date and time in stead of random digit 
$random_digit="fbmini_";

//combine random digit to you file name to create new file name
//use dot (.) to combile these two variables

$new_file_name=$random_digit.$file_name;
//set where you want to store files
//in this example we keep file in folder upload 
//$new_file_name = new upload file name
//for example upload file name cartoon.gif . $path will be upload/cartoon.gif
$path= "upload/".$new_file_name;
if($ufile !=none)
{
if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path))
{
echo "Successful<BR/>";

//$new_file_name = new file name
//$HTTP_POST_FILES['ufile']['size'] = file size
//$HTTP_POST_FILES['ufile']['type'] = type of file
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/>"; 
}
else
{
echo "Error";
}
}
$photo="http://www.facebook.com/dialog/feed?picture=http://facebookmini.zxq.net/upload/.$new_file_name['ufile']['type]."&redirect_uri=http://facebookmini.zxq.net/photoupload.php"
echo "Execute The Following Link In Your Browser To Upload the Photo";
echo $photo;
?>

ERROR IN THE PHP FILE IS - Parse error: syntax error, unexpected T_ECHO in XXXXXX / XXXXX / XXXX / XXXXupload_rename_ac.php on line 71

Recommended Answers

All 4 Replies

Thank You very much ZERO13 , now it's all fine.. thanks for your help , now my website is running smoothly....

Great ! If your problem was solved, then, make it 'Solved Thread'.

ok making it now a solved thread , thanks once again zero13

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.