Jump to content

Recommended Posts

So there are three major problems in my script 

 

  • security

i will do this by my self... so dont judge me for issues in this specific topic i just started this... 

  • upload dir won't work 

instead it drops the file in the main dir where the index lays... and names it with vid instead of putting it to the vid dir

  • it cant upload videos somehow...

i already changed the ini so that files in size of 1gb can be uploaded on to the server.

 

 

there are no errors displayed:

 

Code: 

 

Vidbase.php ->
 

public function doupload ($UID,$TAGS,$VTITLE,$VDESCRIPTION,$VIDEO,$QUESTIONS,$GENRE) {
$dir = "../../VID";
$fname = $VIDEO['name']; 
$ftmp = $VIDEO['tmp_name'];
$ftype = $VIDEO['type'];
$fsize = $VIDEO['size'];
$ferr = $VIDEO['error'];
$fname = preg_replace("/[^A-Z0-9._-]/i", "_", $fname);
if (!$ftmp) {
	$fmsg = "Error: youve not choosen a file please do so in order t upload a file.";
	return $fmsg;
}
if ($ferr !== UPLOAD_ERR_OK) {
    $fmsg = "An error occurred";
    return $fmsg;
    exit;
}
$i = 0;
$parts = pathinfo($fname);
while (file_exists($dir . $fname)) {
    $i++;
    $fname = $parts["filename"] . "-" . $i . "." . $parts["extension"];
}

$success = move_uploaded_file($ftmp, $dir . $fname);
if (!$success) { 
	$fmsg = "upload failed";
	return $fmsg;
    }
	chmod($dir . $fname, 0644);
	$fmsg = "upload complete";
	
	return $fmsg;

}

upload.php

<?php

if (isset($_POST['submit'])) {
  $vid->doupload($userRow['userId'],null,"TITLE","DESCR",$_FILES['file'],null,"tech");
}

?>

<form id="upload_form" enctype="multipart/form-data" method="post">
  <input type="file" name="file" id="file1"><br>
  <button name="submit">UPLOAD</button>
  <progress id="progressBar" value="0" max="100" style="width:300px;"></progress>
  <h3 id="status"></h3>
  <p id="loaded_n_total"></p>
</form>

any sugestions ?

Link to comment
https://forums.phpfreaks.com/topic/301937-video-upload-wont-work/
Share on other sites

Your upload directory path has no trailing slash, and you just append the filename. This will lead to a file with the name “VID...” rather than a file in the “VID” directory.

 

And you indeed don't display any errors. You return a message in your function and don't do anything with it in your main script.

  • Solution

 

Your upload directory path has no trailing slash, and you just append the filename. This will lead to a file with the name “VID...” rather than a file in the “VID” directory.

 

And you indeed don't display any errors. You return a message in your function and don't do anything with it in your main script.

 

--> changed dir var to

 ../../VID/

it works now needed to change the ini a little more...

 

post_max_size
upload_max_filesize
memory_limit

to 1000M 

 

 

thanks alot !  :happy-04:

Edited by AzeS
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.