Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Adjust Php file

Posted on 2013-12-03
5
Medium Priority
?
370 Views
Last Modified: 2013-12-08
Hi,
how to adjust this Php file, if I want to further save the uploaded file into the column with data type - '[varbinary](max)' of a Sql server table?
// Where the file is going to be placed
$target_path = "uploads/";

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['uploadedfile']['name']).
    " has been uploaded";
} else{
    echo "There was an error uploading the file, please try again!";
}

Open in new window

0
Comment
Question by:HuaMinChen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 12

Accepted Solution

by:
Radek Baranowski earned 420 total points
ID: 39694838
you want to store filename or the contents ?

if the content, you'd need to use some way of connecting to your db, in basic php+mysql it'd be:


include("db_cfg.php");

# query below

$q="INSERT ? into `columnname`";

#run query
$r1=mysql_query($q1,$binarycontent);


mysql_close();

hope that helps
0
 
LVL 11

Author Comment

by:HuaMinChen
ID: 39694852
Is there an example to refer to the uploaded file and then do the insert into the table? I am doing this against Sql server.
0
 
LVL 12

Expert Comment

by:Radek Baranowski
ID: 39694855
no, not exactly, it's just and example how to connect to database (on a high level).

you should probably get binary content of the file into variable, not sure how to do this, though.
0
 
LVL 11

Author Comment

by:HuaMinChen
ID: 39694864
I need the exact/sure way to this.
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39698296
Greetings, HuaMinChen.  Here are some general guidelines to make your use of this site more enjoyable and productive for you...

At EE, the experts exchange answers and advice for points.  If you look at the questions awaiting answers in this zone, you will see a lot of 500 point questions.  Your question is competing for the experts' attention among those high-point questions.  So as a matter of simple economics you might be able to envision which questions will get the experts' attention first.   Just a thought.

We are experts, but not mind readers.  Inquiries that are broad, vague and hypothetical may not get answers that are as succinct and effective as inquiries that have actual URLs, complete code examples, and clearly expressed questions.  "It doesn't work" is not an error message.  "I need a complete example" is not a question.  

We answer questions and provide teaching examples, but we cannot build applications for you.  Often a great deal of trial and error, plus a depth of knowledge and background information is necessary to get a piece of an application working.  The experts will try to help, but sometimes the only reasonable answer is, "Please read the fine manuals" or "Be respectful of your time; don't take a year learning this technology -- hire a professional developer and you'll get good results in a couple of weeks."

Best of luck with your project and best regards, ~Ray
0

Featured Post

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question