Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-15-2012, 05:55 PM   PM User | #1
Teknik
New to the CF scene

 
Join Date: Nov 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Teknik is an unknown quantity at this point
Saving Path in Session?

Hey guys.


I'm currently coding a registering form for my brother and i'm having some issue with the uploading section.

I have a form (With name/email etc) and a Upload Video - Click here < This opens a new window where people can browse for a video and select it for upload -

The uploading part works - it checks for things i want it to check for, which is perfect but i need it to do 2 things after it has succesfully uploaded.

1. Save the path of the video uploaded in a Session or something els that i havnt thought about which you can help me with.

2. Close the upload window and make the "click here" link unclickable.



The 2nd part should be easy enough if it can check if a certain Session is set - if so that person wont be able to upload a video until he fills out the entire form and then clicks "Create" which is when it will upload the path (from nr. 1 Session) to Database along with all the other information - once thats don't it should remove all Session.


Here is my code for upload.php which is defined in
PHP Code:
<form enctype="multipart/form-data" action="upload.php" method="POST"
:

PHP Code:
$target "upload/"
 
$target $target basename$_FILES['uploaded']['name']) ; 
 
$ok=1
 
 
//This is our size condition 
 
if ($uploaded_size 350000
 { 
 echo 
"Your file is too large.<br>"
 
$ok=0
 } 
 
 
//This is our limit file type condition 
 
if ($uploaded_type =="text/php"
 { 
 echo 
"No PHP files<br>"
 
$ok=0
 } 
 
 
//Here we check that $ok was not set to 0 by an error 
 
if ($ok==0
 { 
 Echo 
"Sorry your file was not uploaded"
 } 
 if (
file_exists("upload/" $_FILES["file"]["name"]))
      {
      echo 
$_FILES["file"]["name"] . " already exists. ";
      }
      
 
//If everything is ok we try to upload it 
 
else 
 { 
 if(
move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" $_FILES["file"]["name"])) 
 { 
    echo 
"The file "basename$_FILES['uploadedfile']['name']). " has been uploaded"
    echo 
"Upload: " $_FILES["file"]["name"] . "<br />";
    echo 
"Type: " $_FILES["file"]["type"] . "<br />";
    echo 
"Size: " $_FILES["file"]["size"] . " Kb<br />";
    echo 
"Temp file: " $_FILES["file"]["tmp_name"] . "<br />";


 
//$query= "INSERT INTO `mah1231201344051`.`wp_video` (`id`, `name`, `size`, `type`) VALUES (NULL, '$target', '$uploaded_size', '$uploaded_type')";
    //mysql_query($query) or die('Error, query failed');
        
 

 else 
 { 
 echo 
"Sorry, there was a problem uploading your file."
 } 
 } 


Thanks in advance
Teknik is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:04 PM.


Advertisement
Log in to turn off these ads.